如果在控制台中键入命令,则可以正常工作.
但是如果你把它们放在一个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脚本中可用.