BrunoMiranda.com

Personal Blog about Software Engineering, Design, Travel & More

Capistrano 2 local deployment PATH issues

Posted on July 20, 2007 at 02:21 PM

In preparation for my presentation next Monday, July 23, I set out to install and configure Capistrano 2 and ssh locally (OS X) so that I can demonstrate the deployment of a Rails app using Capistrano 2.

I followed the instructions online, setting up a new user called deploy, starting up the ssh server for that user and making sure that all PATH were correct.

A way to test your paths is running

echo $PATH

The above should return the location for the binaries for to ruby, rake, gem, etc are located.

Mine did so, I thought life was great. I created the following recipe:

load 'deploy' if respond_to?(:namespace)

require 'mongrel_cluster/recipes'

set :application, "hello"
set :domain, "localhost"
set :repository, "file:///Users/Bruno/svn/hello/"
set :deploy_to, "/Users/deploy/www/sites/#{application}" 
set :user, "deploy"
set :use_sudo, false
set :scm, :subversion
set :scm_command, "/usr/local/bin/svn"

role :app, domain
role :web, domain
role :db,  domain, :primary => true

namespace :deploy do

  desc "Run after every successful deployment." 
  task :after_default do
    cleanup
  end

  desc "Restart Mongrel"
  task :restart, :roles => :app do
     run "cd /Users/deploy/www/sites/hello/current/ && script/server"
   end

end

Which should be enough to properly deploy and start the mongrel server. That was not the case. I kept getting errors related to cap not being able to find the path to rake or rubygems.

With the help of my fried Chris Saylor, I created a task to inspect the system variables:

  desc "Debug task."
  task(:debug_env) { run "env" }

Upon running the task above I noticed that the path= line was not showing the proper path to where my binaries where located. It should have been:/usr/local/bin

It turns out that I had to set create an ssh environment path in ~/.ssh/environment

PATH=/usr/local/bin:/usr/bin:/usr/sbin

Also, you will need to edit /etc/sshd_config, uncommenting the line that states: PermitUserEnvironment no, and changing the value to yes.

#
PermitUserEnvironment yes
#

After those changes have been made, you should be able to run:

cap deploy:setup
cap deploy

Enjoy!

PS. Thanks to everyone that had the patience to put up with me while I pulled my hair out for 2 days trying to find the answer to this problem, that includes, voxdolo, cwsaylor and queso.

Hierarchy: previous, next

Comments

There are 0 comments on this post. Post yours →

Post a comment

Required fields in bold.

 

Visit the Archives →