运行命令jruby -S spec
出现以下错误
No such file, directory, or command -- spec
spec的位置是/usr/bin
,在路径中。 Rspec 已安装。 MRI Ruby 可以找到该脚本。 JRuby 可以找到 rspec gem。那么出了什么问题呢?
最佳答案
在最新版本的 JRuby 中,当使用 -S
选项时,JRuby 在 3 个不同的位置查找文件:
- 在当前目录中,
- 在 $JRUBY_HOME/bin 中
- 在 PATH(不是 LOAD_PATH)上
这可以通过在 /tmp
中添加一个脚本(此处称为 test_it
,仅打印 hello
)来验证:
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
这里的debug.scriptResolution
选项用于告诉我们脚本在哪里找到。
关于ruby - JRuby 在哪里寻找脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2246062/