[英]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.