Re: [PATCH] instaweb: make the perl path configurable

2013-06-12 Thread Charles McGarvey
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
*mongoose*|*plackup*)
#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)
pid=$!
+   ret=$?
 
-   if test $? != 0; then
+   #If the shell couldn't find perl, try to exec the script file 
directly
+   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
fi

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...

Thanks,

-- 
Charles 

Re: [PATCH] instaweb: make the perl path configurable

2013-06-12 Thread Jakub Narębski
On Wed, Jun 12, 2013 at 8:48 PM, Charles McGarvey
 wrote:
> On 06/12/2013 08:00 AM, Jakub Narebski wrote:
>> Charles McGarvey  brokenzipper.com> writes:
>>
>>> It is convenient for the user to be able to customize the path to perl if 
>>> they
>>> do not want to use the system perl.  This may be the case, for example, if 
>>> the
>>> user wants to use the plackup httpd but its extra dependencies are not
>>> installed in the system perl; they can set the perl path to a perl that they
>>> install and have control over in their own home directory.
>>
>> 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.

> 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?

[...]
> 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?

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

-- 
Jakub Narębski
--
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


Re: [PATCH] instaweb: make the perl path configurable

2013-06-12 Thread Charles McGarvey
On 06/12/2013 08:00 AM, Jakub Narebski wrote:
> Charles McGarvey  brokenzipper.com> writes:
> 
>> It is convenient for the user to be able to customize the path to perl if 
>> they
>> do not want to use the system perl.  This may be the case, for example, if 
>> the
>> user wants to use the plackup httpd but its extra dependencies are not
>> installed in the system perl; they can set the perl path to a perl that they
>> install and have control over in their own home directory.
> 
> 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?

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 and fall back
on the git.git build system-configured perl if there is no perl in PATH.
However, considering the nature of perlbrew, the user may have many different
perls installed and multiple terminals open with shells configured for
different perls.  To make the instaweb command search the PATH for perl would
introduce some unpredictability; the command would succeed or fail depending
on whether or not the perl being "used" in the current shell has the plackup
httpd dependencies installed.  So I think I prefer the ability to configure
which perl to have git always use for instaweb over this approach.

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.

Thanks Jakub,

-- 
Charles McGarvey



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] instaweb: make the perl path configurable

2013-06-12 Thread Jakub Narebski
Charles McGarvey  brokenzipper.com> writes:

> It is convenient for the user to be able to customize the path to perl if they
> do not want to use the system perl.  This may be the case, for example, if the
> user wants to use the plackup httpd but its extra dependencies are not
> installed in the system perl; they can set the perl path to a perl that they
> install and have control over in their own home directory.
> 
> Signed-off-by: Charles McGarvey  brokenzipper.com>

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".

If they do not want to use system perl there is always perlbrew.

> ---
>  Documentation/config.txt | 4 
>  git-instaweb.sh  | 4 +++-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 6e53fc5..e103594 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
>  -1549,6 +1549,10  instaweb.modulepath::
>   instead of /usr/lib/apache2/modules.  Only used if httpd
>   is Apache.
> 
> +instaweb.perlpath::
> + The path to the perl executable used by linkgit:git-instaweb[1] to
> + run gitweb and/or verify that the HTTP daemon is running.
> +
[...]

-- 
Jakub Narębski
(via GMane)


--
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