Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Capistrano

I'm deploying to a VPS using capistrano, based on the guide at RailsCasts. http://railscasts.com/episodes/335-deploying-to-a-vps?view=asciicast

It's failing on the deploy:cold command, with a conflict with Ruby. I actually can't see what the problem is, as when I shell into the same user the Ruby version looks correct.

$ cap shell
cap> which ruby
[establishing connection(s) to 192.xxx.xxx.xxx]
 ** [out :: 192.xxx.xxx.xxx] /home/deployer/.rbenv/shims/ruby
cap> ruby -v
** [out :: 192.xxx.xxx.xxx ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]

This is the error:

command finished in 655ms
* 2013-07-01 16:40:39 executing `bundle:install'
* executing "cd /home/deployer/rails/assay/releases/20130701144038 && bundle install --  gemfile /home/deployer/rails/assay/releases/20130701144038/Gemfile --path   /home/deployer/rails/assay/shared/bundle --deployment --quiet --without development test"
servers: ["192.xxx.xxx.xxx"]
[192.xxx.xxx.xxx] executing command
** [out :: 192.xxx.xxx.xxx] rbenv: version `1.9.3' is not installed
command finished in 662ms
*** [deploy:update_code] rolling back

My question is: how can I debug this? When I read the deploy.rb file I can't see where it even references the Ruby version. Pretty frustrating, I am about ready to ftp the repo up, which is not ideal obviously.

like image 626
port5432 Avatar asked Jul 01 '13 16:07

port5432


People also ask

How does Capistrano work?

At its core, Capistrano uses tasks provided by the Rake build tool to describe various actions that will update and deploy your application. It then supercharges these tasks with its own intuitive DSL that helps execute commands in Unix shell on a local machine or a remote server.

What is Capistrano gem?

The Capistrano project provides a gem called capistrano-gem that lets you easily configure RVM. To include it in your project, add it to your Gemfile within your development group, and run bundle install again. gem "capistrano-rvm" Update your Capfile with the capistrano-rvm import: # Capfile require 'capistrano/rvm'


2 Answers

Well I finally got to the bottom of the issue - a mismatch between ruby versions use by Capistrano and what was actually on the server.

To debug Capistrano run it like this:

cap deploy:cold  -d

That was you can step through the commands and access the temporary directories on the remote server before they are deleted.

like image 200
port5432 Avatar answered Nov 15 '22 10:11

port5432


I just had similar issue, the reason was .ruby-version file pointing at 1.9.3 (file was generated by rails-composer), while there was 1.9.3-p392 installed via rbenv on remote machine.

like image 41
cthulhu Avatar answered Nov 15 '22 10:11

cthulhu