[英]how to use rvm in shell scripting
是否可以在 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.