在Shell脚本中切换红宝石 [英] Switching rubies in shell script
问题描述
执行bash shell脚本时,我使用的是ruby 1.9.3.然后,在脚本中,我想切换到JRub(我正在使用rvm).我尝试通过在脚本中执行rvm use jruby
切换到JRuby,但这没有用,它说:
When executing a bash shell script I am using ruby 1.9.3. Then, within the script, I want to switch to JRub (I'm using rvm). I tried switching to JRuby by doing rvm use jruby
within the script, but this didn't work, it said:
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脚本.我再次收到错误消息.
When I do type rvm | head -n1
at the command prompt, I get: rvm is a function
. So I'm not sure of the problem. I thought it might be because I installed JRuby using sudo (sudo rvm install jruby
). So I ran the shell script again using sudo. Again I received the error.
如何使用rvm从bash shell脚本中切换红宝石?
How can I switch rubies from within a bash shell script with rvm?
谢谢
推荐答案
我最终将其添加到以下行:
I ended up adding this to the line before:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
如该线程中所述(很抱歉-虽然我之前知道此线程,但我不太了解它):
as explained in this thread (sorry - though I was aware of this thread before, I didn't quite grasp it):
这篇关于在Shell脚本中切换红宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!