Reputation: 42420
Running the command jruby -S spec
gives the following error
No such file, directory, or command -- spec
The location of spec is /usr/bin
, which is in the path. Rspec is installed. MRI Ruby can find the script. JRuby can find the rspec gem. So what goes wrong?
Upvotes: 2
Views: 1574
Reputation: 26753
With the latest version of JRuby, when using the -S
option, JRuby looks for the file in 3 different locations:
This can be verified by adding a script (here called test_it
that merely prints hello
) in /tmp
:
sebastien@greystones:~$ jruby -v
jruby 1.6.6.dev (ruby-1.8.7-p357) (2012-01-22 9099561) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_30) [linux-amd64-java]
sebastien@greystones:~$ jruby -S test_it
jruby: No such file or directory -- test_it (LoadError)
sebastien@greystones:~$ export PATH=/tmp:$PATH
sebastien@greystones:~$ jruby -J-Djruby.debug.scriptResolution=true -S test_it
Found: /tmp/test_it
hello
Here the debug.scriptResolution
option is used to tell us where the script has been found.
Upvotes: 2
Reputation: 10318
JRuby will try to load scripts from directories on the classpath. You can see what these are by running:
jruby -e "puts $:"
On the command line you can modify the $LOAD_PATH with the -I option. Or add a library with the -r option. For example:
jruby -I/usr/bin spec
Here is some more info on loadpath and classpath:
http://kenai.com/projects/jruby/pages/ClasspathAndLoadPath
Hope that helps
Upvotes: 2