在shell脚本中切换rubies

时间:2012-11-13 13:16:10

标签: shell rvm jruby

执行bash shell脚本时,我使用的是ruby 1.9.3。然后,在脚本中,我想切换到JRub(我正在使用rvm)。我尝试在脚本中执行rvm use jruby切换到JRuby,但这不起作用,它说:

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.

./run.sh: line 10: jruby: command not found

当我在命令提示符处type rvm | head -n1时,我得到:rvm is a function。所以我不确定这个问题。我想可能是因为我使用sudo(sudo rvm install jruby)安装了JRuby。所以我使用sudo再次运行shell脚本。我再次收到错误。

如何使用rvm从bash shell脚本中切换rubies?

由于

2 个答案:

答案 0 :(得分:6)

我最终将此添加到该行之前:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

正如在这个帖子中所解释的那样(对不起 - 虽然我以前知道过这个帖子,但我并没有完全掌握它):

RVM doesn't switch Rubies

答案 1 :(得分:0)

/ complete / path / to / rvm你的shell似乎定义了'rvm'内置命令。

相关问题