为什么RVM不像bash脚本那样在交互式shell中工作?

Che*_*eng 6 bash rvm

如果在控制台中键入命令,则可以正常工作.

但是如果你把它们放在一个bash脚本中,就会出现问题.

#!/bin/bash
rvm use 1.8.7
rvm list #  This shows the ruby used in parent shell's rvm.
Run Code Online (Sandbox Code Playgroud)

小智 8

RVM安装的shell函数不一定导出到子shell.在shell脚本中,您可以使用.bash_profile或.bashrc中的相同命令行重新初始化RVM:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Run Code Online (Sandbox Code Playgroud)

执行此操作后,rvm函数将在shell脚本中可用.


Way*_*uin 7

在脚本中,您很可能不会将rvm作为函数加载.

http://rvm.io/rvm/basics/