Trouble with migrate over Switchtower

I’m not shy about my love for Switchtower. It’s a great tool that speeds up deployment ten fold (at a minimum). Lately though I’ve run into an issue trying to run migrations over Switchtower. Migrations, if you are not familiar, are a nice way to package your database schema changes into Ruby code, that can then be committed to the repository and applied to both working copies and the production server with ease. For more of an introduction, check out this screencast.

So I’ll prepare a migration and commit it to the repository. I’ll then do a deploy to get the latest version up on the production server. Next, I’ll run the following to tell the production server to run a migration:

rake remote_exec ACTION=migrate

Here is some of the output:

loading configuration ./config/deploy.rb executing task migrate executing "cd /webserver/cbwebsite/current && rake RAILS_ENV=production migrate" servers: ["clickablebliss.com"] processing command [clickablebliss.com] executing command [out :: clickablebliss.com] bash: line 1: rake: command not found command finished rake aborted! command "cd /webserver/cbwebsite/current && rake RAILS_ENV=production migrate" failed on clickablebliss.com

The key line being, bash: line 1: rake: command not found.

I have no idea why this can’t find the rake command. If I ssh into the production machine and manually run that command, it works fine. I previously set up my paths in both .bashrc and .bash_login. During some troubleshooting I even added a ~/.ssh/environment file and added the PATH there —- nothing seems to fix this.

Any ideas?

UPDATE: Jamis Buck responds via the Ruby on Rails mailing list…

Where is rake located on your target machine? Note that .bashrc and .bash_login are not read by the SSH process, and there have been reports of ~/.ssh/environment not working, either, for some people.

However, you can set the :rake variable in your deploy.rb to specify the full path to the rake executable on the remote host(s):

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

I have done so and it’s now working. Thanks Jamis.

Posted on: February 1, 2006 – 1:36 AM

Post a Comment | Comment RSS feed

(used for gravatar), address not displayed on site)