ENV["PATH"] is being overwritten (in Ruby 1.4.6)

K

Ken Innes

I'm having a weird problem where accessing the PATH environment
variable overwrites it with a different path. As an example:

/scripts/script1.rb:
#!/usr/bin/ruby
puts `env | grep PATH`
puts ENV["PATH"]
puts `/usr/bin/env | grep PATH`

Command Line:
[testing]% script1.rb
/bin:/usr/bin:/usr/local/bin:.:/scripts
/bin:/usr
PATH=/bin:/usr
[testing]%

I have to put the full path for "env" the second time otherwise I'd
get "sh: env: command not found". And I don't know where the "/usr"
directory comes from. I've searched all the files in my home
directory, and don't see it setting just "/usr" to the path anywhere.
I also searched through the files in the Ruby directory and never see
a "/usr" by itself.

This is a project that I inherited which uses Ruby 1.4.6 on a RedHat
Linux 6.1J. I copied it onto my RedHat Linux 6.1J machine, and
upgraded Ruby to fix the problem. Unfortunately, the scripts are not
quite compatible with the updated Ruby, so I had to revert to the
version that was originally used.
 
K

Ken Innes

I'm having a weird problem where accessing the PATH environment
variable overwrites it with a different path. As an example:

/scripts/script1.rb:
#!/usr/bin/ruby
puts `env | grep PATH`
puts ENV["PATH"]
puts `/usr/bin/env | grep PATH`

Command Line:
[testing]% script1.rb
/bin:/usr/bin:/usr/local/bin:.:/scripts
/bin:/usr
PATH=/bin:/usr
[testing]%

I have to put the full path for "env" the second time otherwise I'd
get "sh: env: command not found". And I don't know where the "/usr"
directory comes from. I've searched all the files in my home
directory, and don't see it setting just "/usr" to the path anywhere.
I also searched through the files in the Ruby directory and never see
a "/usr" by itself.

This is a project that I inherited which uses Ruby 1.4.6 on a RedHat
Linux 6.1J. I copied it onto my RedHat Linux 6.1J machine, and
upgraded Ruby to fix the problem. Unfortunately, the scripts are not
quite compatible with the updated Ruby, so I had to revert to the
version that was originally used.

I did more testing, and found that the path is getting truncated after
"/bin:/usr". My .tcshrc looked like so:
set path = ( /bin )
set path = ( $path /usr/bin )
set path = ( $path /usr/local/bin )
set path = ( $path . )
set path = ( $path /scripts )

Then I added a few lines, and it still truncated at the same spot:
set path = ( /bin )
set path = ( $path /test1/usr )
set path = ( $path /test1/usr/test2 )
set path = ( $path /usr/bin )
set path = ( $path /usr/local/bin )
set path = ( $path . )
set path = ( $path /scripts )

Gave this after executing the script:
PATH=/bin:/test1/usr:/test1/usr/test2:/usr

However, it does not seem to truncate at all if put /usr as the first
one:
set path = ( /usr )
set path = ( $path /bin )
set path = ( $path /usr/bin )
set path = ( $path /usr/local/bin )
set path = ( $path . )
set path = ( $path /scripts )

I really don't understand this at all.
 
E

Eric Hodel

--H7DA0n3a+SnB4bJ2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
(e-mail address removed) (Ken Innes) wrote in message news:<70452692.0411081= (e-mail address removed)>...
I'm having a weird problem where accessing the PATH environment
variable overwrites it with a different path. As an example:
=20
/scripts/script1.rb:
#!/usr/bin/ruby
puts `env | grep PATH`
puts ENV["PATH"]
puts `/usr/bin/env | grep PATH`
=20
Command Line:
[testing]% script1.rb
/bin:/usr/bin:/usr/local/bin:.:/scripts
/bin:/usr
PATH=3D/bin:/usr
[testing]%
=20
I have to put the full path for "env" the second time otherwise I'd
get "sh: env: command not found". And I don't know where the "/usr"
directory comes from. I've searched all the files in my home
directory, and don't see it setting just "/usr" to the path anywhere.
I also searched through the files in the Ruby directory and never see
a "/usr" by itself.
=20
This is a project that I inherited which uses Ruby 1.4.6 on a RedHat
Linux 6.1J. I copied it onto my RedHat Linux 6.1J machine, and
upgraded Ruby to fix the problem. Unfortunately, the scripts are not
quite compatible with the updated Ruby, so I had to revert to the
version that was originally used.
=20
I did more testing, and found that the path is getting truncated after
"/bin:/usr". My .tcshrc looked like so:

[path snippage]
I really don't understand this at all.

A thought came up on IRC:

Are you using RedHat's Ruby 1.4.6, or a hand-built one? RedHat has been
known to "fix" packages in the past. Either tcsh or ruby may have been
modified to give this behavior. You can find a Ruby 1.4.6 source
tarball from a mirror off of ruby-lang.org. (Holler if you can't find
it.)

Second, are there any binaries or scripts in /usr? It is unusual to
have anything other than directories in that path, perhaps your version
of tcsh has a bug that truncates the path when nothing executable is
found?

--=20
Eric Hodel - (e-mail address removed) - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04


--H7DA0n3a+SnB4bJ2
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQFBkPvCMypVHHlsnwQRAl5tAJ0Rkh7vSRIzO15SExa+Nmr7aTQoogCcCSnj
VeFed7HVSknLR8sToj5SSRU=
=bD1M
-----END PGP SIGNATURE-----

--H7DA0n3a+SnB4bJ2--
 
P

primehalo

Eric said:
Ken said:
(e-mail address removed) (Ken Innes) wrote in message
I'm having a weird problem where accessing the PATH environment
variable overwrites it with a different path. As an example:

/scripts/script1.rb:
#!/usr/bin/ruby
puts `env | grep PATH`
puts ENV["PATH"]
puts `/usr/bin/env | grep PATH`

Command Line:
[testing]% script1.rb
/bin:/usr/bin:/usr/local/bin:.:/scripts
/bin:/usr
PATH=/bin:/usr
[testing]%

I have to put the full path for "env" the second time otherwise I'd
get "sh: env: command not found". And I don't know where the "/usr"
directory comes from. I've searched all the files in my home
directory, and don't see it setting just "/usr" to the path anywhere.
I also searched through the files in the Ruby directory and never see
a "/usr" by itself.

This is a project that I inherited which uses Ruby 1.4.6 on a RedHat
Linux 6.1J. I copied it onto my RedHat Linux 6.1J machine, and
upgraded Ruby to fix the problem. Unfortunately, the scripts are not
quite compatible with the updated Ruby, so I had to revert to the
version that was originally used.

I did more testing, and found that the path is getting truncated after
"/bin:/usr". My .tcshrc looked like so:

[path snippage]
I really don't understand this at all.

A thought came up on IRC:

Are you using RedHat's Ruby 1.4.6, or a hand-built one? RedHat has been
known to "fix" packages in the past. Either tcsh or ruby may have been
modified to give this behavior. You can find a Ruby 1.4.6 source
tarball from a mirror off of ruby-lang.org. (Holler if you can't find
it.)

Second, are there any binaries or scripts in /usr? It is unusual to
have anything other than directories in that path, perhaps your version
of tcsh has a bug that truncates the path when nothing executable is
found?

I originally installed the RedHat version of Ruby (ruby-1.4.6.tar.gz),
then I switched to the Ruby that the original developers had included
with the project (also ruby-1.4.6.tar.gz). I switched in hopes it would
fix the problem, but it made no difference. There was nothing special
about the install except that I had to specify host:
% ./configure --host=i686-pc-linux
% make
% make test
% make install

How would I tell if tcsh was modified? I installed this version of
Linux myself, and nobody else here touches it.

There is nothing in the /usr directory besides other directories. In my
test, I created blank directories but they didn't get truncated.
 
E

Eric Hodel

Eric said:
Ken said:
(e-mail address removed) (Ken Innes) wrote in message

I did more testing, and found that the path is getting truncated
after
"/bin:/usr". My .tcshrc looked like so:

[path snippage]
I really don't understand this at all.

A thought came up on IRC:

Are you using RedHat's Ruby 1.4.6, or a hand-built one? RedHat has
been
known to "fix" packages in the past. Either tcsh or ruby may have
been
modified to give this behavior. You can find a Ruby 1.4.6 source
tarball from a mirror off of ruby-lang.org. (Holler if you can't find
it.)

Second, are there any binaries or scripts in /usr? It is unusual to
have anything other than directories in that path, perhaps your
version
of tcsh has a bug that truncates the path when nothing executable is
found?

I originally installed the RedHat version of Ruby (ruby-1.4.6.tar.gz),
then I switched to the Ruby that the original developers had included
with the project (also ruby-1.4.6.tar.gz). I switched in hopes it would
fix the problem, but it made no difference. There was nothing special
about the install except that I had to specify host:
% ./configure --host=i686-pc-linux
% make
% make test
% make install

How would I tell if tcsh was modified? I installed this version of
Linux myself, and nobody else here touches it.

If you installed it using only RedHat 6 packages, you have have a
modified version of tcsh. The only way to tell would be to install the
same version of tcsh from original sources and see if the problem goes
away.
There is nothing in the /usr directory besides other directories. In my
test, I created blank directories but they didn't get truncated.

Try removing /usr from your path, since it won't help you find any
binaries... Maybe it truncates the path because it has only
directories?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top