Capistrano deploy fails with rvm-shell saying rvm not being found

1.1k views Asked by At

Recently I inherited a Rails application that has been deployed to production many times. I have previously deployed to a staging environment. Now, it fails to deploy to either. However, another Rails application that deploys to the same servers with the same account successfully deploys using rvm and capistrano.

I am receiving the following error:

  * executing "if [ -d /path/to/app/shared/cached-copy ]; then svn switch -q --username svnusername --password <filtered> --no-auth-cache  -r111111 https://svn.server.local/svn/projects/app/trunk /path/to/app/shared/cached-copy; else svn checkout -q --username svnusername --password <filtered> --no-auth-cache  -r111111 https://svn.server.local/svn/projects/app/trunk /path/to/app/shared/cached-copy; fi"
    servers: ["myserver-prod01.private.local"]
    [myserver-prod01.private.local] executing command
 ** [myserver-prod01.private.local:: out]
 ** [myserver-prod01.private.local:: out] $rvm_path (/home/appuser/.rvm/) does not exist.
 ** [myserver-prod01.private.local:: out] /usr/local/rvm/scripts/rvm: line 174: rvm_is_a_shell_function: command not found
 ** [myserver-prod01.private.local:: out] /usr/local/rvm/scripts/rvm: line 185: __rvm_teardown: command not found
 ** [myserver-prod01.private.local:: out] /usr/local/rvm/bin/rvm-shell: line 83: rvm: command not found
 ** [myserver-prod01.private.local:: out] Error: RVM was unable to use 'ruby-1.9.3-current@appuser'
    command finished in 554ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /path/to/app/releases/20130425150643; true"
    servers: ["myserver-prod01.private.local"]
    [myserver-prod01.private.local] executing command
 ** [out :: myserver-prod01.private.local] 
 ** [out :: myserver-prod01.private.local] $rvm_path (/home/appuser/.rvm/) does not exist.
 ** [out :: myserver-prod01.private.local] /usr/local/rvm/scripts/rvm: line 174:     rvm_is_a_shell_function: command not found
 ** [out :: myserver-prod01.private.local] /usr/local/rvm/scripts/rvm: line 185: __rvm_teardown: command not found
 ** [out :: myserver-prod01.private.local] /usr/local/rvm/bin/rvm-shell: line 83: rvm: command not found
 ** [out :: myserver-prod01.private.local] Error: RVM was unable to use 'ruby-1.9.3-current@appuser'
    command finished in 209ms
 ** [deploy:update_code] exception while rolling back: Capistrano::CommandError, failed: "env PATH=/opt/toolkit/extra-dev-current/root/usr/bin:$PATH:/usr/database/bin LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 RAILS_ENV=production rvm_path=$HOME/.rvm/ /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-current@appuser' -c 'rm -rf /path/to/app/releases/20130425150643; true'" on myserver-prod01.private.local
failed: "env PATH=/opt/toolkit/extra-dev-current/root/usr/bin:$PATH:/usr/database/bin LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 RAILS_ENV=production rvm_path=$HOME/.rvm/ /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-current@appuser' -c 'if [ -d /path/to/app/shared/cached-copy ]; then svn switch -q --username svnusername --password <filtered> --no-auth-cache  -r111111 https://svn.server.local/svn/projects/app/trunk /path/to/app/shared/cached-copy; else svn checkout -q --username svnusername --password <filtered> --no-auth-cache  -r111111 https://svn.server.local/svn/projects/app/trunk /path/to/app/shared/cached-copy; fi'" on myserver-prod01.private.local

I have checked the server. RVM is installed and working.

1

There are 1 answers

0
James On

This is an rvm/rvm-capistrano version mismatch. Check the version of rvm installed on the server and compare to the version of rvm-capistrano installed with bundle. If your server has rvm 1.18.x, then lock the version of rvm in your Gemfile to 1.2.x. rvm-capistrano 1.3.x requires rvm 1.19.x.

I am answering my own question because I had to figure this out the hard way. It is obvious in retrospect, but not when you first see the error. This is a case of failure to specify product versions in the Gemfile. Generally, our extensive test suite catches such problems, but our test suite does not cover deploy so we missed this one until it was too late.