我刚刚在 Debian 6 服务器上安装了 RVM,一开始没有任何问题。但是,在设置完所有内容后,我无法在终端中运行RVM。键入rvm use
时收到的消息是:
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.
我正在通过SSH登录,但找不到此问题的解决方案。在"rvm安装不起作用:"RVM不是一个功能"中,他们设法解决了问题,但没有解决SSH。
运行:
rvm get stable --auto-dotfiles
它将从 shell 初始化文件中删除并重新添加 RVM 行
要使ssh
连接正常工作,您需要将 shell 设置为 bash
(首选)或 zsh
,您可以使用以下命令检查当前的 shell:
getent passwd $USER | awk -F: '{print $NF}'
如果不bash
/zsh
更改它:
chsh $USER --shell `which bash`
你需要先获取/etc/profile.d/rvm.sh
。将以下行添加到.bashrc
(或在提示符下键入):
source /etc/profile.d/rvm.sh
或者,如果您需要一个函数,以下脚本对我有用:
#!/bin/sh
#RVM stuff
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$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"
else
printf "ERROR: An RVM installation was not found.n"
fi
当SSH启动bash时,bash在默认版本中不会获取.bashrc(有一个编译时标志,SSH_SOURCE_BASHRC
,强制它这样做)。尝试在SSH命令行中使用类似以下内容:
ssh user@host "bash -i"
请参阅 ssh 命令执行不考虑 .bashrc | .bash_login | .ssh/rc?。