Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RVM is not working over SSH

Tags:

RVM is not working over SSH.

At the command-line:

leifg@host:~$ which ruby /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby 

Connected over SSH:

local:~$ ssh leifg@server 'which ruby' /usr/bin/ruby 

I'm using Ubuntu 11.04.

How do I get SSH to use the same Ruby as it is on the system?

I already verified some prequisites:

  • Ruby was already installed using apt-get install ruby. Does that make any difference?
  • sshd_config has the option "PermitUserEnvironment yes", and I restarted the daemon.

The .bashrc on the server contains these lines, but I see the same behavior when I remove them:

if [ -s "$HOME/.rvm/scripts/rvm" ] ; then   . "$HOME/.rvm/scripts/rvm" elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then   . "/usr/local/rvm/scripts/rvm" fi 
like image 690
leifg Avatar asked Aug 02 '11 20:08

leifg


People also ask

What is RVM command?

RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

Can you use RVM on Windows?

RVM supports most UNIX like systems and Windows (with Cygwin or Bash on Ubuntu on Windows). The basic requirements are bash , curl , gpg2 and overall GNU version of tools - but RVM tries to autodetect it and install anything that is needed.


1 Answers

Actually, your ~/.bashrc will be executed. The problem is usually that one adds the

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* 

... snippet at the bottom of the file. However, the default .bashrc on ubuntu systems includes the following near the top

# If not running interactively, don't do anything [ -z "$PS1" ] && return 

That call will stop executing the rest of the script and will therefore not set the proper paths. So you can either put the rvm call at the top of the file or remove the return call.

like image 170
zoomix Avatar answered Sep 21 '22 12:09

zoomix