Here's a Ruby file at /path/to/test/test.rb
:
# /path/to/test/test.rb
puts 'foobar'
Here's what happens when I run it:
$ cd /path/to/test/
$ ruby test.rb
foobar
So far, so good. But:
$ cd ..
$ ruby test/test.rb
/path/to/test/ # <=== wtf?
foobar
Why does Ruby print the path to the script when I run it outside the current folder? The problem occurs only with Ruby scripts, and occurs whether or not I run it with $ ruby test.rb
or make it executable with a shebang.
This is definitely nonstandard behavior caused by something in my Ruby environment, but I can't imagine what it is. I have Rails and a number of other gems installed. Any idea what might cause this?
Aucun commentaire:
Enregistrer un commentaire