larryzhao
larryzhao

Reputation: 3213

Capistrano using the wrong release path

I am now trying to deploy my application to my ubuntu server-11.04(hostname: chicago), but every time I run cap deploy:update, I always get the following error:

 ** [chicago :: out] push something
 ** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/images': No such file or directory
 ** [out :: chicago] 
 ** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/stylesheets'
 ** [out :: chicago] : No such file or directory
 ** [out :: chicago] find: `/var/deploy/ziya/releases/20120113085410/public/javascripts'
 ** [out :: chicago] : No such file or directory
 ** [out :: chicago] (in /var/deploy/ziya/releases/20120113085410)
 ** [out :: chicago] Could not find rake-0.9.2.2 in any of the sources
 ** [out :: chicago] Run `bundle install` to install missing gems.
*** [deploy:update_code] rolling back
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '1.9.2@ziya' -c 'cd /var/deploy/ziya/releases/20120113085410 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on chicago

But when I check on the server: there's no release: 20120113085410

larry@chicago:/var/deploy/ziya/releases$ ls -l
total 16
drwxrwxr-x 17 larry larry 4096 Jan  6 14:28 20120106024740
drwxrwxr-x 19 larry larry 4096 Jan 12 21:39 20120112065325
drwxrwxr-x 17 larry larry 4096 Jan 13 15:24 20120113072414
drwxrwxr-x 17 larry larry 4096 Jan 13 15:26 20120113072621

following is my deploy.rb,

set :application, "ziya"
server "chicago", :app, :web, :db, :primary => true

# setup scm:
set :repository,  "git@myhost:myuser/ziya.git"
set :deploy_via, :remote_cache
set :scm_username, "myuser"
set :scm, :git
set :scm_verbose, "true"
set :branch, "master"

set(:releases_path)     { File.join(deploy_to, version_dir) }
set(:shared_path)       { File.join(deploy_to, shared_dir) }
set(:current_path)      { File.join(deploy_to, current_dir) }
set(:release_path)      { File.join(releases_path, release_name) }

# ssh to the deploy server
default_run_options[:pty] = true

set :deploy_to, "/var/deploy/#{application}"

after 'deploy:update_code' do
  run "cd #{release_path}; RAILS_ENV=production rake assets:precompile"
end

# 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
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

and following is my Capfile:

$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano"                  # Load RVM's capistrano plugin.
set :rvm_ruby_string, '1.9.2@ziya'

load 'deploy' if respond_to?(:namespace) # cap2 differentiator

# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'

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

And I also expect that there something wrong for the rvm configurations, because I am not so sure about that part..

Upvotes: 0

Views: 3258

Answers (1)

Arun Kumar Arjunan
Arun Kumar Arjunan

Reputation: 6857

You have written an after-hook to pre-compile the assets. You don't have to do that because the following line(which you already have in your code) will do that for you.

load 'deploy/assets'

Add this line to bundle the gems in production environment:

require "bundler/capistrano"

If you still face the issue with rake-not-found error, try using bundle exec rake

To summarize: You need to first bundle-install & then pre-compile the assets.

By the way, the rollback command will remove the folder if the deployment fails. That is why you are not able to find the mentioned directory.

Upvotes: 1

Related Questions