是否可以在shell脚本中加载rvm。任何人都可以给出一个例子。
当我尝试一个shell脚本。我正在使用ubuntu系统
#!/bin/bash
rvm use 1.9.3
它给了我错误
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.
您可以通过执行以下操作在脚本中包含rvm:
source ~/.rvm/scripts/rvm
然后rvm应该可用于你的脚本,
对于简单地对RVM托管的Ruby(或系统Ruby)执行命令,请执行以下操作:
rvm 1.9.3 exec camper_van
这假定 rvm use 1.9.3
和 gem install camper_van
发生在以前提供的 camper_van
可执行
注意:RVM预计已经加载 - 通常用于在用户下启动的脚本( RVM is not a function, selecting rubies with 'rvm use ...'
确认它已经存在)。
# Load RVM into a shell session *as a function*
# Loading RVM *as a function* is mandatory
# so that we can use 'rvm use <specific version>'
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
echo "using user install $HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
source "/usr/local/rvm/scripts/rvm"
echo "using root install /usr/local/rvm/scripts/rvm"
else
echo "ERROR: An RVM installation was not found.\n"
fi