gpt4 book ai didi

ruby - JRuby 在哪里寻找脚本?

转载 作者:数据小太阳 更新时间:2023-10-29 08:41:53 25 4
gpt4 key购买 nike

运行命令 jruby -S spec 出现以下错误

No such file, directory, or command -- spec

spec的位置是/usr/bin,在路径中。 Rspec 已安装。 MRI Ruby 可以找到脚本。 JRuby 可以找到 rspec gem。那么出了什么问题呢?

最佳答案

在最新版本的 JRuby 中,当使用 -S 选项时,JRuby 在 3 个不同的位置查找文件:

  1. 在当前目录下,
  2. 在 $JRUBY_HOME/bin 中
  3. 在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com