I'm currently in the process of attempting my first Rails deployment using Capistrano, and I've run into a roadblock I haven't been able to overcome. During the cap deploy I'm getting an error "mkdir: cannot create directory/public'`".
Pertinent Details:
Rails Version: 3.2.6
Capistrano Version: 2.13.5
Running on Dreamhost
I'm precompiling my assets (I suspect this is part of the problem), so I've got load 'deploy/assets' in my Capfile.
I've followed the directions here: http://wiki.dreamhost.com/Capistrano for the most part, as well as scouring the web for a number of other articles on Capistrano.
deploy.rb
require "bundler/capistrano"
ssh_options[:forward_agent] = true
ssh_options[File.join(ENV["HOME"], ".ssh", "id_rsa-dreamhost")]
set :application, "<app>"
set :repository, "git#bitbucket.org:<gituser>/#{application}.git"
set :server_name, "<host>"
set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :checkout, "export"
set :deploy_via, :remote_cache
set :branch, "master"
set :base_path, "/home/<user>/<domain>"
set :deploy_to, "#{base_path}/#{application}"
set :keep_releases, 3
set :user, '<user>'
set :runner, '<user>'
set :use_sudo, false
default_run_options[:pty] = true
set :shared_path, "/home/<user>/<shared_folder>"
set :release_path, "#{base_path}/#{application}"
role :web, "<host>" # Your HTTP server, Apache/etc
role :app, "<host>" # This may be the same as your `Web` server
role :db, "<host>", :primary => true # This is where Rails migrations will run
# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
desc "Restart the app by touching the restart.txt file."
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
end
desc "Update the environment-specific files from the shared folder."
task :symlink_shared, :roles => [:app] do
run "ln -s #{shared_path}/app_config.yml #{release_path}/config/"
run "rm #{release_path}/config/database.yml"
run "ln -s #{shared_path}/database.yml #{release_path}/config/"
run "rm #{release_path}/public/.htaccess"
run "ln -s #{shared_path}/.htaccess #{release_path}/public/"
end
end
before "deploy:restart", "deploy:symlink_shared"
after "deploy:update_code", "deploy:migrate"
Output of cap deploy:setup
* 2012-12-23 16:49:27 executing `deploy:setup'
* executing "mkdir -p /home/<user>/<domain>/<app> /home/<user>/<domain>/<app>/releases /home/<user>/<shared_folder> /home/<user>/<shared_folder>/system /home/<user>/<shared_folder>/log /home/<user>/<shared_folder>/pids"
servers: ["<host>"]
[<host>] executing command
command finished in 263ms
* executing "chmod g+w /home/<user>/<domain>/<app> /home/<user>/<domain>/<app>/releases /home/<user>/<shared_folder> /home/<user>/<shared_folder>/system /home/<user>/<shared_folder>/log /home/<user>/<shared_folder>/pids"
servers: ["<host>"]
[<host>] executing command
command finished in 261ms
Output of cap deploy:check
* 2012-12-23 16:49:45 executing `deploy:check'
* executing "test -d /home/<user>/<domain>/<app>/releases"
servers: ["<host>"]
[<host>] executing command
command finished in 265ms
* executing "test -w /home/<user>/<domain>/<app>"
servers: ["<host>"]
[<host>] executing command
command finished in 256ms
* executing "test -w /home/<user>/<domain>/<app>/releases"
servers: ["<host>"]
[<host>] executing command
command finished in 256ms
* executing "which git"
servers: ["<host>"]
[<host>] executing command
command finished in 259ms
* executing "test -w /home/<user>/<shared_folder>"
servers: ["<host>"]
[<host>] executing command
command finished in 263ms
You appear to have all necessary dependencies installed
Output of cap:deploy
* 2012-12-23 16:51:41 executing `deploy'
* 2012-12-23 16:51:41 executing `deploy:update'
** transaction: start
* 2012-12-23 16:51:41 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git#bitbucket.org:<gituser>/<app>.git master"
command finished in 1102ms
* executing "if [ -d /home/<user>/<shared_folder>/cached-copy ]; then cd /home/<user>/<shared_folder>/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 42dfb6a3f529e2293192f5e22c3214b7da55c9b4 && git clean -q -d -x -f; else git clone -q git#bitbucket.org:<gituser>/<app>.git /home/<user>/<shared_folder>/cached-copy && cd /home/<user>/<shared_folder>/cached-copy && git checkout -q -b deploy 42dfb6a3f529e2293192f5e22c3214b7da55c9b4; fi"
servers: ["<host>"]
[<host>] executing command
command finished in 3233ms
copying the cached version to /home/<user>/<domain>/<app>
* executing "cp -RPp /home/<user>/<shared_folder>/cached-copy /home/<user>/<domain>/<app> && (echo 42dfb6a3f529e2293192f5e22c3214b7da55c9b4 > /home/<user>/<domain>/<app>/REVISION)"
servers: ["<host>"]
[<host>] executing command
command finished in 338ms
* 2012-12-23 16:51:47 executing `deploy:finalize_update'
triggering before callbacks for `deploy:finalize_update'
* 2012-12-23 16:51:47 executing `deploy:assets:symlink'
* executing "ls -x /home/<user>/<domain>/<app>/releases"
servers: ["<host>"]
[<host>] executing command
command finished in 252ms
* executing "rm -rf /public/assets &&\\\n mkdir -p /public &&\\\n mkdir -p /home/<user>/<shared_folder>/assets &&\\\n ln -s /home/<user>/<shared_folder>/assets /public/assets"
servers: ["<host>"]
[<host>] executing command
** [out :: <host>] mkdir: cannot create directory `/public'
** [out :: <host>] : Permission denied
command finished in 268ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/<user>/<domain>/<app>; true"
servers: ["<host>"]
[<host>] executing command
command finished in 265ms
failed: "sh -c 'rm -rf /public/assets &&\\\n mkdir -p /public &&\\\n mkdir -p /home/<user>/<shared_folder>/assets &&\\\n ln -s /home/<user>/<shared_folder>/assets /public/assets'" on <host>
You can see the Permission denied error near the bottom of the output, as well as the failed shell command at the end. I can't figure out why it is attempting to do anything with /public, as I would expect a relative path to public in my web folder, rather than referring to what appears to be a public folder on root. I feel like I'm missing a variable reference somewhere which should get prepended to the mkdir command, but none of of the documentation I've read indicates this.
I'd appreciate any help I can get, and thanks in advance.
Please don't set release_path and shared_path by yourself. Let Capistrano figure it out automatically.
But you should set deploy_to correctly:
set :deploy_to, "/home/<user>/<domain>/<application>"
Also be careful with variables. The set syntax of Capistrano doesn't mean the variables are available for substitution. Your problem occurs because of "#{base_path}/" is nil and evalutates to "/".
Find out more on the configuration wiki of Capistrano.
Related
I'm running a rails app using JRuby 1.7.1 with Torquebox and trying to deploy on EC2 but I'm seeing the following error when I run 'cap deploy':
* 2013-10-08 21:28:55 executing `deploy'
* 2013-10-08 21:28:55 executing `deploy:update'
** transaction: start
* 2013-10-08 21:28:55 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote https://github.com/mygithubhandle/myreponame.git master"
command finished in 503ms
* executing "if [ -d /opt/apps/myappname/shared/cached-copy ]; then cd /opt/apps/myappname/shared/cached-copy && git fetch origin && git fetch --tags origin && git reset --hard 3c4a0fa3d6d2d67979b117439092d652896b3e44 && git clean -d -x -f; else git clone -b master /opt/apps/myappname/shared/cached-copy && cd /opt/apps/myappname/shared/cached-copy && git checkout -b deploy 3c4a0fa3d6d2d67979b117439092d652896b3e44; fi"myappname/shared/cached-copy && git fetch origin && git fetch --tags origin && git reset --hard 3c4a0fa3d6d2d67979b117439092d652896b3e44 && git clean -d -x -f; else git clone -b master https://github.com/mygithubhandle/myreponame.git /opt/apps/myappname/shared/cached-copy && cd /opt/apps/myappname/shared/cached-copy && git checkout -b deploy 3c4a0fa3d6d2d67979b117439092d652896b3e44; fi"
servers: ["XX.XXX.XXX.XX"]
[ec2-user#XX.XXX.XXX.XX] executing command
** [XX.XXX.XXX.XX :: out] sh: git: command not found
command finished in 268ms
*** [deploy:update_code] rolling back
* executing "rm -rf /opt/apps/pickemup-api/releases/20131009042856; true"
servers: ["XX.XXX.XXX.XX"]
[ec2-user#XX.XXX.XXX.XX] executing command
command finished in 259ms
failed: "env JRUBY_OPTS=--1.9 PATH=/opt/torquebox/current/jboss/bin:/opt/torquebox/current/jruby/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/root/bin sh -c 'if [ -d /opt/apps/myappname/shared/cached-copy ]; then cd /opt/apps/myappname/shared/cached-copy && git fetch origin && git fetch --tags origin && git reset --hard 3c4a0fa3d6d2d67979b117439092d652896b3e44 && git clean -d -x -f; else git clone -b master https://github.com/mygithubhandle/myreponame.git /opt/apps/myappname/shared/cached-copy && cd /opt/apps/myappname/shared/cached-copy && git checkout -b deploy 3c4a0fa3d6d2d67979b117439092d652896b3e44; fi'" on ec2-user#XX.XXX.XXX.XX
My deploy.rb file:
require 'torquebox-capistrano-support'
require 'bundler/capistrano'
set :ssh_options, {:forward_agent => true}
server "ec2-user#XX.XXX.XXX.XX", :web, :app, :primary => true
set :repository, "https://github.com/mygithubhandle/mygithubrepo.git"
set :branch, "master"
set :user, "torquebox"
set :scm, :git
set :scm_verbose, true
set :use_sudo, false
set :deploy_via, :remote_cache
default_run_options[:pty] = true
ssh_options[:auth_methods] = ["publickey"]
ssh_options[:keys] = ["path/to/my/pem/key"]
set :deploy_to, "/opt/apps/myappname"
set :torquebox_home, "/opt/torquebox/current"
set :jboss_init_script, "/etc/init.d/jboss-as-standalone"
set :rails_env, 'production'
set :app_context, "/"
set :app_ruby_version, '1.9'
set :application, "myappname"
set :jruby_home, '/usr/local/jruby'
default_environment['JRUBY_OPTS'] = '--1.9'
default_environment['PATH'] = '/opt/torquebox/current/jboss/bin:/opt/torquebox/current/jruby/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/root/bin'
after 'deploy:update_code', 'deploy:assets:precompile'
after 'deploy:update', 'deploy:resymlink'
before 'deploy:finalize_update', 'deploy:assets:symlink'
namespace :deploy do
desc "relink db directory"
#if you use sqlite
task :resymlink, :roles => :app do
run "mkdir -p #{shared_path}/db; rm -rf #{current_path}/db && ln -s #{shared_path}/db #{current_path}/db && chown -R torquebox:torquebox #{current_path}/db"
end
# This is a weird part. I've found that asset complation with JRuby can really hog up the memory, which can cause the application to crash
# when doing a deploy. So, I like to compile the assets locally and SCP them to the server instead.
# Just make sure you've commented out the load deploy/assets in your Capfile.
namespace :assets do
# If you want to force the compilation of assets, just set the ENV['COMPILE_ASSETS']
task :precompile, :roles => :web do
force_compile = ENV['COMPILE_ASSETS']
begin # on first deploys, there is no current_revision so an error gets raised. in this case we want to just compile assets and upload them.
from = source.next_revision(current_revision)
rescue
force_compile = true
end
if ( force_compile) or (capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0 )
run_locally("rake assets:clean && rake assets:precompile")
run_locally "cd public && tar -jcf assets.tar.bz2 assets"
top.upload "public/assets.tar.bz2", "#{shared_path}", :via => :scp
run "cd #{shared_path} && tar -jxf assets.tar.bz2 && rm assets.tar.bz2"
run_locally "rm public/assets.tar.bz2"
run_locally("rake assets:clean")
else
logger.info "Skipping asset precompilation because there were no asset changes"
end
end
task :symlink, roles: :web do
run ("rm -rf #{latest_release}/public/assets &&
mkdir -p #{latest_release}/public &&
mkdir -p #{shared_path}/assets &&
ln -s #{shared_path}/assets #{latest_release}/public/assets")
end
end
end
Any ideas on what could be going wrong here?
Git client isn't installed on the box you are deploying to. You can fix it by logging in as root to your ec2 instance and installing get. (yum install git or apt-get install git)
Or you can change your deployment strategy to copy, which is slower than :remote_cache. Copy will checkout on your local machine and scp/sftp all the files over to the server being deployed to.
set :deploy_via, :copy
You need "git" in your system. apt-get install git should do the trick. However, there are a few more possible issues you can stumble upon. I have written an article on my company's blog to document my struggle and solution.
I've set the deploy_to variable to the necessary path, but Capistrano runs a single task in the u/app/ directory.
Here is the task that is run
executing "cat /u/apps/application/current/REVISION"
That is how variables are set
set :application, "application"
set :deploy_to, "normal_path/#{application}"
Part of the log where it happens is here:
* executing "cat /normal_path/applicaiton/TOUCH_ASSETS | while read asset; do touch -cm -- \"$asset\"; done && rm -f -- /normal/TOUCH_ASSETS"
servers: ["1.1.1.1"]
[1.1.1.1] executing command
command finished in 992ms
* executing "cat /u/apps/application/current/REVISION"
servers: ["1.1.1.1"]
[1.1.1.1] executing command
command finished in 427ms
*** [deploy:update_code] rolling back
* executing "rm -rf /normal_path/applicaiton/releases/20130610233146; true"
servers: ["1.1.1.1", "1.1.1.2"]
[1.1.1.1] executing command
[1.1.1.1] executing command
command finished in 486ms
failed: "sh -c 'cat /u/apps/application/current/REVISION'" on 1.1.1.1
Why does Capistrano use the wrong path?
What is the proper way to deploy:setup and to do a cold deploy with Capistrano?
Using
this deploy.rb
Capistrano v2.14.2
Vagrant to virtualize my server,
this is my scenario:
when running deploy:setup, Capistrano makes use of root privileges to prepare the directory structure for deployment:
$ cap deploy:setup
* 2013-02-28 14:50:21 executing `deploy:setup'
* executing "sudo -p 'sudo password: ' mkdir -p /home/vagrant/example /home/vagrant/example/releases /home/vagrant/example/shared /home/vagrant/example/shared/system /home/vagrant/example/shared/log /home/vagrant/example/shared/pids"
servers: ["example.com"]
[example.com] executing command
command finished in 29ms
* executing "sudo -p 'sudo password: ' chmod g+w /home/vagrant/example /home/vagrant/example/releases /home/vagrant/example/shared /home/vagrant/example/shared/system /home/vagrant/example/shared/log /home/vagrant/example/shared/pids"
servers: ["example.com"]
[example.com] executing command
command finished in 11ms
yet upon deploy:cold Capistrano attempts to checkout (from git in this case) and write as the vagrant user – the user specified in deploy.rb:
$ cap deploy:cold
* 2013-02-28 14:50:47 executing `deploy:cold'
* 2013-02-28 14:50:47 executing `deploy:update'
** transaction: start
* 2013-02-28 14:50:47 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git#github.com:mariusbutuc/realtime-faye.git master"
command finished in 2360ms
* executing "if [ -d /home/vagrant/example/shared/cached-copy ]; then cd /home/vagrant/example/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard a7c05516bc31c2c18f89057c02f84bfad83a6b59 && git clean -q -d -x -f; else git clone -q git#github.com:mariusbutuc/realtime-faye.git /home/vagrant/example/shared/cached-copy && cd /home/vagrant/example/shared/cached-copy && git checkout -q -b deploy a7c05516bc31c2c18f89057c02f84bfad83a6b59; fi"
servers: ["example.com"]
[example.com] executing command
** [example.com :: out] fatal: could not create work tree dir '/home/vagrant/example/shared/cached-copy'.: Permission denied
command finished in 26ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/vagrant/example/releases/20130228195049; true"
servers: ["example.com"]
[example.com] executing command
command finished in 7ms
failed: "sh -c 'if [ -d /home/vagrant/example/shared/cached-copy ]; then cd /home/vagrant/example/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard a7c05516bc31c2c18f89057c02f84bfad83a6b59 && git clean -q -d -x -f; else git clone -q git#github.com:mariusbutuc/realtime-faye.git /home/vagrant/example/shared/cached-copy && cd /home/vagrant/example/shared/cached-copy && git checkout -q -b deploy a7c05516bc31c2c18f89057c02f84bfad83a6b59; fi'" on example.com
Of course, the deploy:check report bares no surprises: the vagrant user cannot write in the directories created during deploy:setup since the two users belong to different groups – root:root versus vagrant:vagrant:
$ cap deploy:check
[...]
The following dependencies failed. Please check them and try again:
--> You do not have permissions to write to `/home/vagrant/example'. (example.com)
--> You do not have permissions to write to `/home/vagrant/example/releases'. (example.com)
--> `/home/vagrant/example/shared' is not writable (example.com)
What is the reasoning behind this, and what prerequisite is not satisfied yet so the deployment passes this issue?
The deploy:setup task probably should not be using sudo to create the app directory, since that is likely causing it to be owned by root.
You can turn that off in your deploy.rb file with:
set :use_sudo, false
Since there are no group setting in Capistrano my workaround is to extend such a setting, for example:
set :user, 'vagrant'
set :group, 'vagrant'
and then create a task to "fix" the ownership after running deploy:setup:
after "deploy:setup", :setup_ownership
task :setup_ownership do
run "#{sudo} chown -R #{user}:#{group} #{deploy_to} && chmod -R g+s #{deploy_to}"
end
But the only thing better than fixing an issue is not having it in the first place, so Stuart's answer is both wiser and more elegant.
I am really stuck with this deployment, I am using Ryan Bates code from railcasts on deploying with capistrano.
Here is my deploy
require "bundler/capistrano"
load "config/recipes/base"
load "config/recipes/nginx"
load "config/recipes/unicorn"
load "config/recipes/postgresql"
load "config/recipes/nodejs"
load "config/recipes/rbenv"
load "config/recipes/check"
server "37.188.126.99", :web, :app, :db, primary: true
set :user, "deployer"
set :application, "TWL"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
#set :repository, "git#github.com:acooperman/#{application}.git"
set :repository, "git#github.com:acooperman/TWL.git"
#set :repository, "https://github.com/acooperman/TWL.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
And here is the result :
$ cap deploy:update
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git#github.com:acooperman/TWL.git master"
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deployer/apps/TWL/releases/20120611173529; true"
servers: ["37.188.126.99"]
Password:
[37.188.126.99] executing command
command finished in 340ms
Command git ls-remote git#github.com:acooperman/TWL.git master returned status code pid 3500 exit 128
If I swap the comments on the line
set :repository, "git#github.com:acooperman/TWL.git"
#set :repository, "https://github.com/acooperman/TWL.git"
I get the following :
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote https://github.com/acooperman/TWL.git master"
Username for 'https://github.com':
Password for 'https://acooperman#github.com':
command finished in 7893ms
* executing "if [ -d /home/deployer/apps/TWL/shared/cached-copy ]; then cd /home/deployer/apps/TWL/shared/cached-copy && git
fetch -q origin && git fetch --tags -q origin && git reset -q --hard 418c9e9b1d7b37427a76e6bf98a17722f3a9e863 && git clean -q
-d -x -f; else git clone -q https://github.com/acooperman/TWL.git /home/deployer/apps/TWL/shared/cached-copy && cd /home/depl
oyer/apps/TWL/shared/cached-copy && git checkout -q -b deploy 418c9e9b1d7b37427a76e6bf98a17722f3a9e863; fi"
servers: ["37.188.126.99"]
Password:
[37.188.126.99] executing command
** [37.188.126.99 :: out] error: The requested URL returned error: 401 while accessing https://github.com/acooperman/TWL.git/
info/refs
**
** fatal: HTTP request failed
command finished in 1590ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deployer/apps/TWL/releases/20120611173441; true"
servers: ["37.188.126.99"]
[37.188.126.99] executing command
command finished in 331ms
failed: "sh -c 'if [ -d /home/deployer/apps/TWL/shared/cached-copy ]; then cd /home/deployer/apps/TWL/shared/cached-copy && gi
t fetch -q origin && git fetch --tags -q origin && git reset -q --hard 418c9e9b1d7b37427a76e6bf98a17722f3a9e863 && git clean -
q -d -x -f; else git clone -q https://github.com/acooperman/TWL.git /home/deployer/apps/TWL/shared/cached-copy && cd /home/dep
loyer/apps/TWL/shared/cached-copy && git checkout -q -b deploy 418c9e9b1d7b37427a76e6bf98a17722f3a9e863; fi'" on 37.188.126.99
Git works fine from my new vps and does not require a password.
I really am stuck here and any help would be appreciated, I am completely new to capistrano and fairly new to rails so this really does have me stumped.
Thanks for any help :)
Adam
looks like your ssh key is not in the default location, try setting a pass to your ssh key manually
ssh_options[:keys] = ["PATH TO SSH/id_rsa]
I have a Rails 3.1.1 app that I am trying to deploy via Capistrano. This is my first attempt at this and I have worked through several issues by doing a lot of research, but I have hit a wall that I can not figure out a way to scale.
I can run cap deploy:setup and cap deploy:check without incident. When I try and run cap deploy this is what I get see bottom (separated text concerning the rake 0.9.2.2 and the failed line at the bottom)
Aaron-Johnsons-Macbook-Pro:webd2 aaronjohnsonis$ cap deploy *
executing deploy' * executingdeploy:update' ** transaction:
start * executing deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git#github.com:webdsquared/webd2.git master"
command finished in 2351ms * executing "if [ -d /home/webdsqua/apps/webd2/shared/cached-copy ]; then cd
/home/webdsqua/apps/webd2/shared/cached-copy && git fetch origin &&
git fetch --tags origin && git reset --hard
28e67c5f7e1ed4612dffd2ac4fb287356f51ce3b && git submodule init && for
mod ingit submodule status | awk '{ print $2 }'; do git config -f
.git/config submodule.${mod}.urlgit config -f .gitmodules --get
submodule.${mod}.url&& echo Synced $mod; done && git submodule sync
&& export GIT_RECURSIVE=$([ ! \"git --version\" \\< \"git version
1.6.5\" ] && echo --recursive) && git submodule update --init $GIT_RECURSIVE && git clean -d -x -f; else git clone --depth 1
git#github.com:webdsquared/webd2.git
/home/webdsqua/apps/webd2/shared/cached-copy && cd
/home/webdsqua/apps/webd2/shared/cached-copy && git checkout -b deploy
28e67c5f7e1ed4612dffd2ac4fb287356f51ce3b && git submodule init && git
submodule sync && export GIT_RECURSIVE=$([ ! \"git --version\" \\<
\"git version 1.6.5\" ] && echo --recursive) && git submodule update
--init $GIT_RECURSIVE; fi"
servers: ["webdsquared.com"] Password:
[webdsquared.com] executing command ** [webdsquared.com :: out] HEAD is now at 28e67c5 initial commit
command finished in 2428ms
copying the cached version to /home/webdsqua/apps/webd2/releases/20111104183017 * executing "cp
-RPp /home/webdsqua/apps/webd2/shared/cached-copy /home/webdsqua/apps/webd2/releases/20111104183017 && (echo
28e67c5f7e1ed4612dffd2ac4fb287356f51ce3b >
/home/webdsqua/apps/webd2/releases/20111104183017/REVISION)"
servers: ["webdsquared.com"]
[webdsquared.com] executing command
command finished in 2997ms * executingdeploy:finalize_update'
triggering before callbacks for deploy:finalize_update' * executingdeploy:assets:symlink' * executing "rm -rf
/home/webdsqua/apps/webd2/releases/20111104183017/public/assets &&\\n
mkdir -p /home/webdsqua/apps/webd2/releases/20111104183017/public
&&\\n mkdir -p /home/webdsqua/apps/webd2/shared/assets &&\\n
ln -s /home/webdsqua/apps/webd2/shared/assets
/home/webdsqua/apps/webd2/releases/20111104183017/public/assets"
servers: ["webdsquared.com"]
[webdsquared.com] executing command
command finished in 1104ms * executing "chmod -R g+w /home/webdsqua/apps/webd2/releases/20111104183017"
servers: ["webdsquared.com"]
[webdsquared.com] executing command
command finished in 119ms * executing "rm -rf /home/webdsqua/apps/webd2/releases/20111104183017/log
/home/webdsqua/apps/webd2/releases/20111104183017/public/system
/home/webdsqua/apps/webd2/releases/20111104183017/tmp/pids &&\\n
mkdir -p /home/webdsqua/apps/webd2/releases/20111104183017/public
&&\\n mkdir -p
/home/webdsqua/apps/webd2/releases/20111104183017/tmp &&\\n ln
-s /home/webdsqua/apps/webd2/shared/log /home/webdsqua/apps/webd2/releases/20111104183017/log &&\\n ln
-s /home/webdsqua/apps/webd2/shared/system /home/webdsqua/apps/webd2/releases/20111104183017/public/system &&\\n
ln -s /home/webdsqua/apps/webd2/shared/pids
/home/webdsqua/apps/webd2/releases/20111104183017/tmp/pids"
servers: ["webdsquared.com"]
[webdsquared.com] executing command
command finished in 3136ms
triggering after callbacks for deploy:update_code' * executingdeploy:assets:precompile' * executing "cd
/home/webdsqua/apps/webd2/releases/20111104183017 && rake
RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["webdsquared.com"]
[webdsquared.com] executing command
** [out :: webdsquared.com] (in /home/webdsqua/apps/webd2/releases/20111104183017) ** [out >::
webdsquared.com] Could not find rake-0.9.2.2 in any of the sources
command finished in 1108ms
* [deploy:update_code] rolling back * executing "rm -rf /home/webdsqua/apps/webd2/releases/20111104183017; true"
servers: ["webdsquared.com"]
[webdsquared.com] executing command
**command finished in 113ms failed: "sh -c 'cd /home/webdsqua/apps/webd2/releases/20111104183017 && rake
RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on
webdsquared.com**
My deploy.rb file looks like this...
set :application, "app"
set :repository, "git#github.com:webdsquared/app.git"
set :scm, "git"
set :deploy_to, "/home/username/apps/#{application}"
set :user, "username"
set :use_sudo, false
set :deploy_via, :remote_cache
set :keep_releases, 3
set :normalize_asset_timestamps, false
set :git_enable_submodules, 1
set :branch, "master"
set :git_shallow_clone, 1
set :scm_verbose, true
role :web, "webdsquared.com"
role :app, "webdsquared.com"
role :db, "webdsquared.com", :primary => true
after "deploy", "deploy:restart"
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
The Capfile looks like this...
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
Any advice would be most appreciated. Has anyone experienced the same thing and found a solution?
Thanks in advance.
What version of capistrano are you running? Are you using bundler in your application? The problem is that capistrano is not using bundle exec when running commands... It should be running bundle exec rake... not just rake...