Search code examples
ruby-on-railsruby-on-rails-4capistranounicornrvm-capistrano

Capistrano Deployment failure : /etc/init.d/unicorn: line 42: rvm-shell command not found


I am deploying to Server using Unicorn, and capistrano in rails....

But at the final step of deployment . Capistrano exists out with this error:

 INFO [47010f4f] Running /usr/bin/env service unicorn_app restart on xyzdomain.com
DEBUG [47010f4f] Command: service unicorn_app restart
DEBUG [47010f4f]    Couldn't reload, starting 'cd /var/www/app/current; rvm-shell 'default' -c 'bundle exec unicorn -D -c /var/www/app/shared/config/unicorn.rb -E staging'' instead
DEBUG [47010f4f]    
DEBUG [47010f4f]    /etc/init.d/unicorn_app: line 42: rvm-shell: command not found
DEBUG [47010f4f]    
cap aborted!

When I run rvm-shell command from terminal on the Server, it runs without error.

Note: rvm-shell is installed in ~/.rvm/bin . So it is not the same error as mentioned here :https://github.com/capistrano/capistrano/issues/43

Why is this happening?


Solution

  • Resolved the Problem:

    It was actually some Permissions problem on the Server.

    When I executed the command, which was failing directly on Server, it produced some directory permission errors. I resolved them by creating those directories manually.

    cd /var/www/app/shared
    mkdir pids
    mkdir logs
    

    Strangely Capistrano didn't display specific failure errors when deployment failed, which led to a lot of confusion and wasted time to debug.

    Hope my Answer would help other people if they Get similar kind of error and save lot of their time. :)