Subject: Bug#1133: [X2Go-Dev] Bug#1133: Bug#1133: Inconsistent Perl used by server or its agent on connect

From: Ted Toal <[email-masked]>
Date: Wed, 11 Jan 2017 09:41:35 -0800

Sorry for the mixup about lower case l and capital I.  I don’t know that using a different font would have helped in this case.  I had the wrong one specified and you found it and used it despite the font.  Btw, the web site where I found the option (perlmaven.com) also used a font that didn’t distinguish it, which is how it propagated to me.

Perhaps that option on the shebang is not the best way to handle this.  But you are wrong to think that people should not or will not be setting PERL5LIB in their .bashrc.  It is normal practice among Perl users, and in fact I would guess that the majority of Perl users do so.  And that breaks x2go.  x2go should never assume that the environment variables used by a program it is invoking, especially /usr/lib/perl, will be set the way it wants them set, after .bashrc has run.

ted

> On Jan 11, 2017, at 1:05 AM, Stefan Baur <[email-masked]> wrote:
> 
> Control: close -1
> thanks
> 
> [re-sent as the original message went to Ted's personal mailbox only]
> 
> Am 11.01.2017 um 02:48 schrieb Ted Toal:
>>> perl has the -l option for specifying the PERL5LIB path.  That
> option can, and I think should, be used on the shebang of the x2go perl
> scripts:
>>> 
>>> #!/usr/bin/perl -l /usr/lib/perl5
>>> 
>>> or something like that.  I know the shebang line allows args.
> 
> Ted,
> 
> while we agree that options *can* be used on the shebang line, I
> disagree that they should be used in our scripts for specifying
> something that *is the default*.
> You would, indeed, change the shebang to "#!/usr/bin/perl -T" if you
> wanted to run the script in taint mode, which is a non-default setting.
> 
> Also, the parameter to set the library path is not -l (lower-case L),
> but -I (upper-case i).  I would suggest using a font that displays them
> differently, it makes coding a lot easier.
> 
> Why explicitly setting the PERL5LIB path in the shebang line is a bad
> idea can be shown like this:
> 
> First, run
> perl -e 'print "@INC\n";'
> to display the default.
> 
> On my system, this returns:
> /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2
> /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20
> /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20
> /usr/share/perl/5.20 /usr/local/lib/site_perl .
> 
> Next, run
> perl -I /foo -e 'print "@INC\n";'
> which corresponds to setting -I /foo on the shebang line.
> 
> On my system, this returns:
> /foo /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2
> /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20
> /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20
> /usr/share/perl/5.20 /usr/local/lib/site_perl .
> 
> Notice how the search path is extended, not replaced, by /foo ending up
> at the beginning.
> 
> Now let's see what happens when combining -I *and* a set PERL5LIB variable:
> PERL5LIB=/bar perl -I /foo -e 'print "@INC\n";'
> 
> This results in:
> /foo /bar /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2
> /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20
> /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20
> /usr/share/perl/5.20 /usr/local/lib/site_perl .
> 
> You can see that /foo and /bar are added to the search path, with the
> value of -I taking precedence, as in being listed and thus searched
> first, over PERL5LIB.
> 
> And this is exactly NOT what a user expects, even though it would solve
> your percieved problem:
> 
> Standard Unix practice is that when an environment variable is set, it
> should take precedence over any default, and a command line option set
> should take precedence over any environment variable.
> 
> Adding -I /path/to/libs at the shebang line would break what is expected
> behavior.
> 
> No one keeps you from running a search and replace on all X2Go-related
> scripts after installing them, though ...
> 
> However, I would strongly recommend against that and suggest un-setting
> PERL5LIB in .bashrc when an X2Go-related bash invocation is detected,
> instead.
> 
> Why this doesn't work for you the way it does for us is what we're
> tracking in Bug #1134, so again, closing this bug.
> 
> Kind Regards,
> Stefan Baur
> -- 
> BAUR-ITCS UG (haftungsbeschränkt)
> Geschäftsführer: Stefan Baur
> Eichenäckerweg 10, 89081 Ulm | Registergericht Ulm, HRB 724364
> Fon/Fax 0731 40 34 66-36/-35 | USt-IdNr.: DE268653243
> 
>