为什么与RVM相关的命令无法在shell脚本中运行...但在终端中的行为与预期的一样

时间:2013-10-11 16:23:03

标签: shell rvm

ubuntu@ip-10-114-202-137:~$ sudo ./ghgvc.sh 
./ghgvc.sh: 4: ./ghgvc.sh: rvmsudo: not found
./ghgvc.sh: 5: ./ghgvc.sh: rvm: not found
./ghgvc.sh: 6: ./ghgvc.sh: rvm: not found
./ghgvc.sh: 8: ./ghgvc.sh: source: not found
 SSH back in to re-source RVM 
ubuntu@ip-10-114-202-137:~$ which rvmsudo
/home/ubuntu/.rvm/bin/rvmsudo

上述错误来自此脚本:

if [ "$RVM_RELOADED" ]; then
  echo "RVM was reloaded... proceeding"
else
  rvmsudo rvm get head
  rvm group add rvm $USER
  rvm reload
  echo "export rvm_trust_rvmrcs_flag=1" > ~/.rvmrc  #auto-trust .rvmrc flags  
  source ~/.rvmrc

  export RVM_RELOADED="1"
  echo " SSH back in to re-source RVM "
  exit
fi

1 个答案:

答案 0 :(得分:0)

您使用sudo调用脚本,这将删除整个环境上下文,以完成您尝试执行的操作,而不是source脚本:

source ghgvc.sh