On 06/12/2013 03:03 PM, Jakub Narębski wrote:
> On Wed, Jun 12, 2013 at 8:48 PM, Charles McGarvey wrote:
>> On 06/12/2013 08:00 AM, Jakub Narebski wrote:
>>> Is it really necessary?  There is always PERL5LIB if one wants to use Perl
>>> modules installed in one's own home directory.  If one is using local::lib
>>> one has it "for free".
>> Yes, that's right.  Using PERL5LIB would solve the example problem in the
>> commit message, and it would even be pretty simple to set up using
>> local::lib.  So, no, this isn't strictly necessary.
>>> If they do not want to use system perl there is always perlbrew.
>> Well, perlbrew is actually what I had in mind for this patch.  Without it,
>> it seems like the perl path -- which is configured while building git.git
>> so is not easily changed by the user -- is "hard-coded" in the shebang line
>> of the plackup script file which is then made executable and exec'd, to
>> start the httpd.  Given that process, I don't see how that code allows the
>> user to use any other perl, or am I missing something?
> I am sorry, this is my mistake.  Of course if one is using perlbrew then one
> wants to use perlbrew perl (nb. how does "perlbrew switch" work?), not
> necessarily system perl hardcoded during installation time.

Perlbrew switch works by prepending the dirname of the specified perl to PATH
(and removing paths to "inactive" perls); it is implemented as a shell
function wrapper which is why it can change the current shell's environment.

So yes, searching PATH instead of using the hard-coded perl would allow the
instaweb command to use a perlbrew perl (or any other perl).  I think this
would be better than not being able to use a non-system perl at all, but
a drawback I see -- and I mentioned this before, but I'll just restate it --
is that a perl module developer usually has a lot of perls installed and it
would be up to them to know whether or not the perl that is "active" for the
shell they're currently in has the instaweb dependencies.  It's probably not
an unreasonable burden on the user, but it's something to consider.  If the
perl path were configurable, the user could set it to a perl they know has the
dependencies and not have to deal with any uncertainty in the future whether
or not the git instaweb command would succeed in their current environment.

I think that's the benefit of the current code with hard-coded perl path: it's
more predictable.  In other words, changes in the user's environment won't
change how git (instaweb) works in potentially surprising ways.  I think this
is a benefit worth preserving, which is why the patch introduces a new config
variable rather than using PATH.

>> If adding a new config variable seems too heavy-handed for such a trivial
>> problem, another approach would be to use the first perl in PATH
> Hmmm... git moved out of using first "perl" in PATH...
>> and fall back
>> on the git.git build system-configured perl if there is no perl in PATH.
> How to do this?

If you wanted to use PATH, I guess you could first try to invoke perl
explicitly and let the shell search PATH implicitly, such as the following
(except it doesn't make sense to do this for mongoose, so the case would need
to be split).

@@ -110,11 +110,19 @@ start_httpd () {
        case "$httpd" in
                #These servers don't have a daemon mode so we'll have to fork it
-               $full_httpd "$conf" &
+               perl "$full_httpd" "$conf" &
                #Save the pid before doing anything else (we'll print it later)
+               ret=$?
-               if test $? != 0; then
+               #If the shell couldn't find perl, try to exec the script file 
+               if test $ret = 127; then
+                       $full_httpd "$conf" &
+                       pid=$!
+                       ret=$?
+               fi
+               if test $ret != 0; then
                        echo "Could not execute http daemon $httpd."
                        exit 1

I'm also not completely certain how this would affect win32 users, though
I suspect it would work fine with the same caveats.

> [...]
>> In short summary, this patch isn't necessary because everyone could use
>> local::lib to manage dependencies not installed at the system level, but I
>> think this patch is desirable for those of us who use perlbrew and not
>> local::lib.  Of course, I'm open to alternatives and other suggestions.
> One other thing to think about is: why here, and not other places?

I'm not familiar enough with git.git to know whether this problem exists for
other components.  If so, and if a solution can be agreed upon, definitely
let's fix it at every place or perhaps come up with a broader solution.  I'll
spend some time poking around in the code.

> Nb. for short Perl scripts not using extra modules we pick first "perl"
> in PATH, IIRC...


Charles McGarvey
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to