Eric Hodel <drbrain / segment7.net> wrote in message news:<20041106073536.GK93473 / segment7.net>...
> Ken Innes (primehalo / hotmail.com) wrote:
> 
> > Well, "setenv RUBYLIB /scripts" was the right solution. I don't quite
> > understand what was going on; RUBYLIB was set (as verified by typing
> > "setenv"), but Ruby couldn't find the scripts until I restarted the
> > computer. Then it seemed to work fine.
> > 
> > But now I'm having another weird problem where accessing the PATH
> > environment variable is causing Ruby not find scripts. For example:
> >      /scripts/script1.rb:
> >           #!/usr/bin/ruby
> >           print `script3.rb`
> > 
> >      /scripts/script2.rb:
> >           #!/usr/bin/ruby
> >           ENV["PATH"].split(/:/).each { |i|
> >                #do nothing
> >           }
> >           print `script3.rb`
> > 
> >      /scripts/script3.rb:
> >           #!/usr/bin/ruby
> >           print "Testing...\n"
> > 
> >      Command Prompt:
> >           [scripts]# cd /testing
> >           [testing]# script1.rb
> >           Testing....
> >           [testing]# script2.rb
> >           /testing/script2:4: command not found: script3
> > 
> > Any access to ENV["PATH"] seems to cause the problem, for example:
> > print ENV["PATH"]
> > tmp = ENV["PATH"]
> > ENV["PATH"].chomp!
> > 
> > Any ideas on this one?
> 
> Looking at the code for ENV.[], I don't see anything that would cause
> this, unless there's some bug in your libc with getenv.
> 
> Perhaps you should try a bash-like shell instead of a csh-like shell?
> 
> Oh, try this:
> 
> puts ENV["PATH"]
> puts `env | grep path`
> 
> See if your PATH is really destroyed.

My default shell is bash, but I change to csh to run their scripts (as
that's what it said to do in their readme file). Still, I have tried
it in both shells with the same results.

Anyway, I tried your suggestion, and here's what happens:

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

     Command Line:
          [testing]% script2.rb
          /bin:/usr
          sh: env: command not found
          [testing]%

Didn't work because I referenced ENV["PATH"] so it couldn't find
"env".

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

     Command Line:
          [testing]% script2.rb
          /bin:/usr
          
          [testing]%

Probably put a blank line because of a difference in case.

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

     Command Line:
          [testing]% script2.rb
          /bin:/usr
          PATH=/bin:/usr
          [testing]%

The PATH environment variable still seems to be in tact, but Ruby
still can't find any files that are in PATH directories after
ENV["PATH"] is accessed.