# git-instaweb portability issue (maybe?)

14 messages from 2008-06-13 to 2008-06-13. Participants: Denis Bueno, Asheesh Laroia, Chris Ridd, Luciano Rocha, Jakub Narebski.
Thread: https://gitlist.dev/t/13931

## Denis Bueno, 2008-06-13 13:26

Subject: git-instaweb portability issue (maybe?)
Message-ID: <6dbd4d000806130626pfdb06f2qbfea6f1909710b7b@mail.gmail.com>
URL: https://gitlist.dev/e/6dbd4d000806130626pfdb06f2qbfea6f1909710b7b%40mail.gmail.com

```
Hi,

I'm on OS X 10.4.11 on Intel using git 1.5.5.3.

I'd been trying to use the git-instaweb script (both with and without
arguments) with lighttpd (which I installed through Macports) without
success, seeing the following kind of bizarre error message:

    funsat[290] > git instaweb
    /opt/local/bin/git-instaweb: line 6033: /usr/bin/env perl: No such
file or directory
    2008-06-13 09:09:31: (log.c.75) server started

    funsat[291] > 2008-06-13 09:09:31: (mod_cgi.c.998) CGI failed:
Exec format error /Volumes/work/funsat/.git/gitweb/gitweb.cgi
    mod_cgi.c.1001: aborted
    2008-06-13 09:09:31: (mod_cgi.c.584) cgi died, pid: 23237

"/usr/bin/env perl: No such file or directory"? Huh?  I certainly have
perl installed, so I don't know what that's about.

That line simply calls perl by the $PERL variable, which is set at the
top of the script, like so:

    PERL='/usr/bin/env perl'

If I change this line to point to my perl directly, it works.  On a
hunch, I changed it to:

    PERL="/usr/bin/env perl"  # note the double-quotes

And now it works.  Could this be changed for future releases of git?
Does this in fact increase portability, or is something more sinister
going on?

Thanks.

-- 
 Denis

```

## Denis Bueno, 2008-06-13 13:38

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <6dbd4d000806130638k4461a41eo8ce6fe803505fa88@mail.gmail.com>
URL: https://gitlist.dev/e/6dbd4d000806130638k4461a41eo8ce6fe803505fa88%40mail.gmail.com
In-Reply-To: <6dbd4d000806130626pfdb06f2qbfea6f1909710b7b@mail.gmail.com>

```
On Fri, Jun 13, 2008 at 09:26, Denis Bueno <dbueno@gmail.com> wrote:
> That line simply calls perl by the $PERL variable, which is set at the
> top of the script, like so:
>
>    PERL='/usr/bin/env perl'
>
> If I change this line to point to my perl directly, it works.  On a
> hunch, I changed it to:
>
>    PERL="/usr/bin/env perl"  # note the double-quotes

[snip lies]

Apparently I didn't test this thoroughly enough, and I was wrong.
Changing the quotes has no effect.

So git-instaweb only works for me if I manually specify my perl path.
Can anyone think of why this might be?

-- 
 Denis

```

## Asheesh Laroia, 2008-06-13 13:46

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <alpine.DEB.1.10.0806130946060.8043@alchemy.localdomain>
URL: https://gitlist.dev/e/alpine.DEB.1.10.0806130946060.8043%40alchemy.localdomain
In-Reply-To: <6dbd4d000806130638k4461a41eo8ce6fe803505fa88@mail.gmail.com>

```
On Fri, 13 Jun 2008, Denis Bueno wrote:

> On Fri, Jun 13, 2008 at 09:26, Denis Bueno <dbueno@gmail.com> wrote:
>> That line simply calls perl by the $PERL variable, which is set at the
>> top of the script, like so:
>>
>>    PERL='/usr/bin/env perl'
>>
>> If I change this line to point to my perl directly, it works.  On a
>> hunch, I changed it to:
>>
>>    PERL="/usr/bin/env perl"  # note the double-quotes
>
> [snip lies]
>
> Apparently I didn't test this thoroughly enough, and I was wrong.
> Changing the quotes has no effect.
>
> So git-instaweb only works for me if I manually specify my perl path.
> Can anyone think of why this might be?

Does OS X ship /usr/bin/env?

If you type "/usr/bin/env perl" in a Terminal window, do you get Perl?

-- Asheesh.

-- 
Hark ye, Clinker, you are a most notorious offender.  You stand convicted of
sickness, hunger, wretchedness, and want.
 		-- Tobias Smollet

```

## Denis Bueno, 2008-06-13 13:59

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <6dbd4d000806130659r2a8bc57ev6db4ef058ee97440@mail.gmail.com>
URL: https://gitlist.dev/e/6dbd4d000806130659r2a8bc57ev6db4ef058ee97440%40mail.gmail.com
In-Reply-To: <alpine.DEB.1.10.0806130946060.8043@alchemy.localdomain>

```
On Fri, Jun 13, 2008 at 09:46, Asheesh Laroia <asheesh@asheesh.org> wrote:
> Does OS X ship /usr/bin/env?
>
> If you type "/usr/bin/env perl" in a Terminal window, do you get Perl?

Sorry, I should have made that clear earlier: yes.

funsat[122] > /usr/bin/env perl --version

This is perl, v5.8.8 built for darwin-2level


-- 
 Denis

```

## Chris Ridd, 2008-06-13 14:10

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <48527FEC.8080909@isode.com>
URL: https://gitlist.dev/e/48527FEC.8080909%40isode.com
In-Reply-To: <6dbd4d000806130659r2a8bc57ev6db4ef058ee97440@mail.gmail.com>

```
Denis Bueno wrote:
> On Fri, Jun 13, 2008 at 09:46, Asheesh Laroia <asheesh@asheesh.org> wrote:
>> Does OS X ship /usr/bin/env?
>>
>> If you type "/usr/bin/env perl" in a Terminal window, do you get Perl?
> 
> Sorry, I should have made that clear earlier: yes.
> 
> funsat[122] > /usr/bin/env perl --version
> 
> This is perl, v5.8.8 built for darwin-2level

MacPorts /tends/ to make ports use stuff from other ports instead of 
using Apple-installed bits. In this case, maybe git from MacPorts is 
using perl from MacPorts?

Cheers,

Chris

```

## Asheesh Laroia, 2008-06-13 14:16

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <alpine.DEB.1.10.0806131016120.8043@alchemy.localdomain>
URL: https://gitlist.dev/e/alpine.DEB.1.10.0806131016120.8043%40alchemy.localdomain
In-Reply-To: <48527FEC.8080909@isode.com>

```
On Fri, 13 Jun 2008, Chris Ridd wrote:

> Denis Bueno wrote:
>> On Fri, Jun 13, 2008 at 09:46, Asheesh Laroia <asheesh@asheesh.org> wrote:
>>> Does OS X ship /usr/bin/env?
>>> 
>>> If you type "/usr/bin/env perl" in a Terminal window, do you get Perl?
>> 
>> Sorry, I should have made that clear earlier: yes.
>> 
>> funsat[122] > /usr/bin/env perl --version
>> 
>> This is perl, v5.8.8 built for darwin-2level
>
> MacPorts /tends/ to make ports use stuff from other ports instead of using 
> Apple-installed bits. In this case, maybe git from MacPorts is using perl 
> from MacPorts?

FWIW, the problem seems to be that it's not finding *any* Perl.

-- Asheesh.

-- 
A can of ASPARAGUS, 73 pigeons, some LIVE ammo, and a FROZEN DAQUIRI!!

```

## Luciano Rocha, 2008-06-13 14:21

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <20080613142118.GA20027@bit.office.eurotux.com>
URL: https://gitlist.dev/e/20080613142118.GA20027%40bit.office.eurotux.com
In-Reply-To: <6dbd4d000806130638k4461a41eo8ce6fe803505fa88@mail.gmail.com>

```
On Fri, Jun 13, 2008 at 09:38:18AM -0400, Denis Bueno wrote:
> On Fri, Jun 13, 2008 at 09:26, Denis Bueno <dbueno@gmail.com> wrote:
> > That line simply calls perl by the $PERL variable, which is set at the
> > top of the script, like so:
> >
> >    PERL='/usr/bin/env perl'
> >
> > If I change this line to point to my perl directly, it works.  On a
> > hunch, I changed it to:
> >
> >    PERL="/usr/bin/env perl"  # note the double-quotes
> 
> [snip lies]
> 
> Apparently I didn't test this thoroughly enough, and I was wrong.
> Changing the quotes has no effect.

That makes more sense.

Try changing the following line instead:
	"$PERL" -p -e "$script" "$1.tmp"  > "$1"
to
	$PERL -p -e "$script" "$1.tmp"  > "$1"

about line 6121 of the git-instaweb script.

-- 
Luciano Rocha <luciano@eurotux.com>
Eurotux Informática, S.A. <http://www.eurotux.com/>

```

## Jakub Narebski, 2008-06-13 14:22

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <m3abhpqusj.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3abhpqusj.fsf%40localhost.localdomain
In-Reply-To: <6dbd4d000806130626pfdb06f2qbfea6f1909710b7b@mail.gmail.com>

```
"Denis Bueno" <dbueno@gmail.com> writes:

> I'm on OS X 10.4.11 on Intel using git 1.5.5.3.
> 
> I'd been trying to use the git-instaweb script (both with and without
> arguments) with lighttpd (which I installed through Macports) without
> success, seeing the following kind of bizarre error message:
> 
>     funsat[290] > git instaweb
>     /opt/local/bin/git-instaweb: line 6033: /usr/bin/env perl: No such
> file or directory
>     2008-06-13 09:09:31: (log.c.75) server started
> 
>     funsat[291] > 2008-06-13 09:09:31: (mod_cgi.c.998) CGI failed:
> Exec format error /Volumes/work/funsat/.git/gitweb/gitweb.cgi
>     mod_cgi.c.1001: aborted
>     2008-06-13 09:09:31: (mod_cgi.c.584) cgi died, pid: 23237
> 
> "/usr/bin/env perl: No such file or directory"? Huh?  I certainly have
> perl installed, so I don't know what that's about.
> 
> That line simply calls perl by the $PERL variable, which is set at the
> top of the script, like so:
> 
>     PERL='/usr/bin/env perl'

This depends on how git was build (on compile time configuration).
git-instaweb.sh (source of git-instaweb) has

        PERL='@@PERL@@'

which is set to value of $PERL_PATH (or, to be more exact, its squoted
version) during building git-instaweb.  So you can simply use

  $ make PERL_PATH=/usr/bin/perl
  # make PERL_PATH=/usr/bin/perl install

or whatever, or you can use ./configure script

  $ make configure
  $ ./configure --with-perl=/usr/bin/perl


On Linux for example the path to perl is set explicitely, instead of
using "/usr/bin/env perl" construct.  The 'env' construct has the
following disadvantages:
 - it uses first Perl find in your $PATH, so if git works for you or
   don't work depends on user's personal configuration
   (reproductability, convenience and security).
 - AFAIK it doesn't allow to pass switches to Perl


P.S. Check if you have new enough Perl (there are problems with
Unicode support in old Perl), and if you have CGI.pm new enough
installed for gitweb.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Denis Bueno, 2008-06-13 14:39

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <6dbd4d000806130739r633cb34cx9edbe48724d6a325@mail.gmail.com>
URL: https://gitlist.dev/e/6dbd4d000806130739r633cb34cx9edbe48724d6a325%40mail.gmail.com
In-Reply-To: <20080613142118.GA20027@bit.office.eurotux.com>

```
On Fri, Jun 13, 2008 at 10:21, Luciano Rocha <luciano@eurotux.com> wrote:
> Try changing the following line instead:
>        "$PERL" -p -e "$script" "$1.tmp"  > "$1"
> to
>        $PERL -p -e "$script" "$1.tmp"  > "$1"
>
> about line 6121 of the git-instaweb script.

This is line 6033 for me; however, this change makes it work!  (I
verified my changing this line; trying it; then changing it back to
the double-quotes version, and verifying it breaks.)

Why?

-- 
 Denis

```

## Chris Ridd, 2008-06-13 14:42

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <48528769.2000007@isode.com>
URL: https://gitlist.dev/e/48528769.2000007%40isode.com
In-Reply-To: <alpine.DEB.1.10.0806131016120.8043@alchemy.localdomain>

```
Asheesh Laroia wrote:
> On Fri, 13 Jun 2008, Chris Ridd wrote:
> 
>> Denis Bueno wrote:
>>> On Fri, Jun 13, 2008 at 09:46, Asheesh Laroia <asheesh@asheesh.org> 
>>> wrote:
>>>> Does OS X ship /usr/bin/env?
>>>>
>>>> If you type "/usr/bin/env perl" in a Terminal window, do you get Perl?
>>>
>>> Sorry, I should have made that clear earlier: yes.
>>>
>>> funsat[122] > /usr/bin/env perl --version
>>>
>>> This is perl, v5.8.8 built for darwin-2level
>>
>> MacPorts /tends/ to make ports use stuff from other ports instead of 
>> using Apple-installed bits. In this case, maybe git from MacPorts is 
>> using perl from MacPorts?
> 
> FWIW, the problem seems to be that it's not finding *any* Perl.

That's odd, because the Portfile for git-core (1.5.5.3_0) does the 
build, test and destroot install setting:

PERL_PATH="/usr/bin/env perl" NO_FINK=1 NO_DARWIN_PORTS=1

(and some other stuff). Have you pinged the port maintainer 
(bryan@larsen.st)?

Cheers,

Chris

```

## Denis Bueno, 2008-06-13 14:47

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <6dbd4d000806130747r403cf637t66d59b58b9489e33@mail.gmail.com>
URL: https://gitlist.dev/e/6dbd4d000806130747r403cf637t66d59b58b9489e33%40mail.gmail.com
In-Reply-To: <48528769.2000007@isode.com>

```
On Fri, Jun 13, 2008 at 10:42, Chris Ridd <chris.ridd@isode.com> wrote:
> Asheesh Laroia wrote:
>>
>> On Fri, 13 Jun 2008, Chris Ridd wrote:
>>
>>> Denis Bueno wrote:
>>>>
>>>> On Fri, Jun 13, 2008 at 09:46, Asheesh Laroia <asheesh@asheesh.org>
>>>> wrote:
>>>>>
>>>>> Does OS X ship /usr/bin/env?
>>>>>
>>>>> If you type "/usr/bin/env perl" in a Terminal window, do you get Perl?
>>>>
>>>> Sorry, I should have made that clear earlier: yes.
>>>>
>>>> funsat[122] > /usr/bin/env perl --version
>>>>
>>>> This is perl, v5.8.8 built for darwin-2level
>>>
>>> MacPorts /tends/ to make ports use stuff from other ports instead of
>>> using Apple-installed bits. In this case, maybe git from MacPorts is using
>>> perl from MacPorts?
>>
>> FWIW, the problem seems to be that it's not finding *any* Perl.
>
> That's odd, because the Portfile for git-core (1.5.5.3_0) does the build,
> test and destroot install setting:
>
> PERL_PATH="/usr/bin/env perl" NO_FINK=1 NO_DARWIN_PORTS=1
>
> (and some other stuff). Have you pinged the port maintainer
> (bryan@larsen.st)?

The issue seems to be one of the way bash is treating quotes.  It
apparently is trying to find the *command* "/usr/bin/env perl" and not
executing the command "/usr/bin/env" with a first argument of "perl".

See my message to Luciano moments ago.

-- 
 Denis

```

## Luciano Rocha, 2008-06-13 15:13

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <20080613151307.GA21917@bit.office.eurotux.com>
URL: https://gitlist.dev/e/20080613151307.GA21917%40bit.office.eurotux.com
In-Reply-To: <6dbd4d000806130739r633cb34cx9edbe48724d6a325@mail.gmail.com>

```
On Fri, Jun 13, 2008 at 10:39:11AM -0400, Denis Bueno wrote:
> On Fri, Jun 13, 2008 at 10:21, Luciano Rocha <luciano@eurotux.com> wrote:
> > Try changing the following line instead:
> >        "$PERL" -p -e "$script" "$1.tmp"  > "$1"
> > to
> >        $PERL -p -e "$script" "$1.tmp"  > "$1"
> >
> > about line 6121 of the git-instaweb script.
> 
> This is line 6033 for me; however, this change makes it work!  (I
> verified my changing this line; trying it; then changing it back to
> the double-quotes version, and verifying it breaks.)
> 
> Why?

"$PERL" means the content of the variable is used as the command to
execute.

$PERL, on the other hand, goes through a round of word splitting, that
in your case results in the command "/usr/bin/env", with the arguments
"perl", "-p", ...

Thus, if it is possible to use /usr/bin/env, the current "$PERL"
incantation is incorrect.

-- 
Luciano Rocha <luciano@eurotux.com>
Eurotux Informática, S.A. <http://www.eurotux.com/>

```

## Jakub Narebski, 2008-06-13 15:32

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <m363sdqrk0.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m363sdqrk0.fsf%40localhost.localdomain
In-Reply-To: <20080613151307.GA21917@bit.office.eurotux.com>

```
Luciano Rocha <luciano@eurotux.com> writes:
> On Fri, Jun 13, 2008 at 10:39:11AM -0400, Denis Bueno wrote:
>> On Fri, Jun 13, 2008 at 10:21, Luciano Rocha <luciano@eurotux.com> wrote:
>>>
>>> Try changing the following line instead:
>>>        "$PERL" -p -e "$script" "$1.tmp" > "$1"
>>> to
>>>        $PERL -p -e "$script" "$1.tmp" > "$1"
>>>
>>> about line 6121 of the git-instaweb script.
>> 
>> This is line 6033 for me; however, this change makes it work!  (I
>> verified my changing this line; trying it; then changing it back to
>> the double-quotes version, and verifying it breaks.)
>> 
>> Why?
> 
> "$PERL" means the content of the variable is used as the command to
> execute.
> 
> $PERL, on the other hand, goes through a round of word splitting, that
> in your case results in the command "/usr/bin/env", with the arguments
> "perl", "-p", ...
> 
> Thus, if it is possible to use /usr/bin/env, the current "$PERL"
> incantation is incorrect.

The problem is with trying to ensure that both

   /path/with spaces/perl

and

   /usr/bin/env perl

work, as they require different rules wrt. splitting on whitespace...

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Luciano Rocha, 2008-06-13 15:39

Subject: Re: git-instaweb portability issue (maybe?)
Message-ID: <20080613153913.GB21917@bit.office.eurotux.com>
URL: https://gitlist.dev/e/20080613153913.GB21917%40bit.office.eurotux.com
In-Reply-To: <m363sdqrk0.fsf@localhost.localdomain>

```
On Fri, Jun 13, 2008 at 08:32:20AM -0700, Jakub Narebski wrote:
> Luciano Rocha <luciano@eurotux.com> writes:
> > On Fri, Jun 13, 2008 at 10:39:11AM -0400, Denis Bueno wrote:
> >> On Fri, Jun 13, 2008 at 10:21, Luciano Rocha <luciano@eurotux.com> wrote:
> >>>
> >>> Try changing the following line instead:
> >>>        "$PERL" -p -e "$script" "$1.tmp" > "$1"
> >>> to
> >>>        $PERL -p -e "$script" "$1.tmp" > "$1"
> >>>
> >>> about line 6121 of the git-instaweb script.
> >> 
> >> This is line 6033 for me; however, this change makes it work!  (I
> >> verified my changing this line; trying it; then changing it back to
> >> the double-quotes version, and verifying it breaks.)
> >> 
> >> Why?
> > 
> > "$PERL" means the content of the variable is used as the command to
> > execute.
> > 
> > $PERL, on the other hand, goes through a round of word splitting, that
> > in your case results in the command "/usr/bin/env", with the arguments
> > "perl", "-p", ...
> > 
> > Thus, if it is possible to use /usr/bin/env, the current "$PERL"
> > incantation is incorrect.
> 
> The problem is with trying to ensure that both
> 
>    /path/with spaces/perl
> 
> and
> 
>    /usr/bin/env perl
> 
> work, as they require different rules wrt. splitting on whitespace...

Oh. Then it gets ugly. Can't just "perl" be used? Instead of
"/usr/bin/env perl"?

Otherwise...
if [ -x "$PERL" ]; then
	"$PERL" ...
else
	$PERL ...
fi

-- 
Luciano Rocha <luciano@eurotux.com>
Eurotux Informática, S.A. <http://www.eurotux.com/>

```
