RVM won't work over SSH (as a function)

心已入冬 提交于 2019-12-06 15:14:21

run:

rvm get stable --auto-dotfiles

it will remove and re-add rvm lines from shell initialization files

for ssh connections to work you need to set your shell as bash(preferred) or zsh, you can check your current shell with:

getent passwd $USER | awk -F: '{print $NF}'

and if it is not bash/zsh change it with:

chsh $USER --shell `which bash`

You need to source /etc/profile.d/rvm.sh first. Add the following line to your .bashrc (or type it at the prompt) :

source /etc/profile.d/rvm.sh

Alternatively, if you need a function, the following script works for me :

#!/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
echristopherson

When SSH launches bash, bash doesn't source .bashrc, in default builds (there is a compile-time flag, SSH_SOURCE_BASHRC, that forces it to). Try using something like this in your SSH command line:

ssh user@host "bash -i"

See ssh command execution doesn't consider .bashrc | .bash_login | .ssh/rc?.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!