capistrano errors out with rvm-shell command not found #43

JeanMertz opened this Issue Jun 1, 2011 · 25 comments

I've ran capistrano before on my staging server and was about to deploy on my new production server when I ran into several problems.

This is my cap deploy:check:

several times this error:
bash: /home/apps/.rvm/bin/rvm-shell: No such file or directory

then this conclusion:
The following dependencies failed. Please check them and try again:
--> `/home/apps/manager/releases' does not exist. Please run `cap deploy:setup'. (xxx)
--> You do not have permissions to write to `/home/apps/manager'. (xxx)
--> You do not have permissions to write to `/home/apps/manager/releases'. (xxx)
--> `git' could not be found in the path (
--> `gem' command could not be found. Try setting :gem_command (xxx)
--> gem `bundler' >=1.0.11 could not be found (xxx)

obviously the directory errors can be fixed by using cap deploy:setup

The other errors however, are a mystery to me. when I ssh into my server I can easily use the rvm command and it says it's installed as a function. Furthermore, both git -v and gem -v are working correctly. So why can't capistrano use these commands?

Also, I checked for /home/apps/.rvm/bin, which exists, but there is no rvm-shell command to be found in there? All I see is erb, gem, irb, rake, rdoc, ri, ruby and testrb.

My deploy file looks like this:


bundler details
require "bundler/capistrano"

rvm details
$:.unshift(File.expand_path("./lib", ENV["rvm_path"]))
require "rvm/capistrano"
set :rvm_ruby_string, "1.9.2@manager"
set :rvm_type, :user

application details
set :application, "manager"

repo details
set :scm, :git
set :repository, "xxx"
set :branch, "master"

server details
ssh_options[:forward_agent] = true
set :deploy_to, "/home/apps/#{application}"
set :deploy_via, :remote_cache
set :user, "apps"
set :use_sudo, false

runtime dependencies
depend :remote, :gem, "bundler", ">=1.0.11"

role :web, "xxx"
role :app, "xxx"
role :db,  "xxx", primary: true

set :rails_env, "production"

I've installed rvm as a user, which is the only difference from the staging server, so I guess this has something to do with it, but capistrano is looking in the right directory, it just can't find rvm-shell, is this an rvm installation problem, or is it related to my deploy.rb file or anything?


I just completely reinstalled rvm as a user again, without any errors, and the rvm-shell command is still not in ~/.rvm/bin/rvm-shell. Can capistrano only work if I install rvm as root?


I found out rvm installed the rvm-shell command (and some others) in ~/bin instead of ~/.rvm/bin. So I'm closing this for now, as I assume it's actually a problem with rvm or my installation steps.

@JeanMertz JeanMertz closed this Jun 1, 2011
Capistrano member

Why is this closed? I have freshly installed 1.6.20 today and this is a new issue for me. As JeanMertz indicated, rvm-shell is being installed in ~$HOME/bin and not ~$HOME/.rvm/bin. Clearly out of sync with capistrano.rb.

Capistrano member

@doug316 because incorrectly installing/configuring RVM, and their Capistrano extension, which they maintain not working isn't a Capistrano bug. I refer you to their Github repository where the capistrano.rb file lives


Has anyone found a solution to this? Still erroring out with:

/home/vmontalb/.rvm/bin/rvm-shell: No such file or directory

failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.2-p180'

I can clearly see that the files are in ~/bin instead of ~/.rvm/bin


I was able to get around the issue for now by symlinking the files into that directory:

ln ~/bin/rvm-shell ~/.rvm/bin/rvm-shell && ln ~/bin/rvm ~/.rvm/bin/rvm && ln ~/bin/rvm-auto-ruby ~/.rvm/bin/rvm-auto-ruby && ln ~/bin/rvm-exec ~/.rvm/bin/rvm-exec && ln ~/bin/rvm-installer ~/.rvm/bin/rvm-installer && ln ~/bin/rvm-prompt ~/.rvm/bin/rvm-prompt && ln ~/bin/rvmsudo ~/.rvm/bin/rvmsudo

Capistrano member

I have this problem, I installed rvm today with

$ bash < <(curl -s

Capistrano member

as long this is not fixed by upstream rvm you can set the bin path in you deploy.rb

set :rvm_bin_path, "$HOME/bin"
Capistrano member

As long this is not fixed by upstream rvm you can set the bin path in you deploy.rb

Thanks for the tip @niklas, another RVM option, I guess they should change the default!


@niklas nice tip worked out for me too!


Thank @niklas! Worked for me.


This worked for me:

require 'bundler/capistrano'

$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :rvm_ruby_string, '1.9.2'

set :rvm_bin_path, "/usr/local/bin"

Yep, this totally worked. Thanks!


Thank you @niklas... worked like a charm!


Thank you guys for the hints above.
My rvm-shell is in /usr/local/rvm/bin, so the following worked for me:

require 'bundler/capistrano'

$:.unshift(File.expand_path('./lib', ENV['rvm_path']))  # Add RVM's lib directory to the load path.
require "rvm/capistrano"                                # Load RVM's capistrano plugin.
set :rvm_ruby_string, 'ruby-1.9.2@myapp'             # Or whatever env you want it to run in.
set :rvm_bin_path, "/usr/local/rvm/bin"

rvm installs in /usr/local/rvm/bin for me... got same error as original issue

Capistrano member

OK, please no more "me too" - this is RVMs problem, when their Capistrano integration doesn't work with their defaults, it's not our issue. Also, I'm far from convinced that a user-space environment management tool belongs in a hosted server environment.


Wow, leehambley called it back in June, and no one reported it to them? Come on people!

Reported to RVM:


Capistrano member

@dgm thanks for taking the time to report that upstream. (I wasn't doing it on principle)


Ubuntu: 11+

set :rvm_bin_path, "/usr/share/ruby-rvm/bin"

Having same issue and trying to understand where this :rvm_bin_path is documented (why always variables are so badly documented in every project ? even Capistrano variables are note completly documented. Don't misunderstand me; I'm very happy with Capistrano :) ),
I found in the code ( the following procedure :

  # Define rvm_path
  # This is used in the default_shell command to pass the required variable to rvm-shell, allowing
  # rvm to boostrap using the proper path. This is being lost in Capistrano due to the lack of a
  # full environment.
  _cset(:rvm_path) do
    case rvm_type
    when :root, :system
    when :local, :user, :default
      rvm_type.to_s.empty? ? "$HOME/.rvm" : rvm_type.to_s

  # Let users override the rvm_bin_path
  _cset(:rvm_bin_path) do
    case rvm_type
    when :root, :system
    when :local, :user, :default
      rvm_type.to_s.empty? ? "#{rvm_path}/bin" : rvm_type.to_s

So it looks like rvm developers are aware of the case, and the :rvm_type variable exist to solve this case.
If fact it depend if you installed rvm as user or with "sudo", or as a root.
Following instruction on :

 Please note that this defaults to using a user installation of rvm. If you wish to instead set it to use an system wide (root) install, add the following to your Capfile deploy.rb :

set :rvm_type, :system  # Copy the exact line. I really mean :system here*

So those having rvm bin stored in /usr/local/rvm/bin, should set :rvm_type with :system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment