Search code examples
deploymentruby-on-rails-3.1capistrano

Capistrano compile assets error - assets:precompile:nondigest?


My App seems to be deploying correctly but I'm getting this error:

      * executing "cd /home/deploy/tomahawk/releases/20120208222225 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
    servers: ["ip_address"]
    [ip_address] executing command
*** [err :: ip_address] /opt/ruby/bin/ruby /opt/ruby/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets

I've tried solutions here for trying to compile assets: http://lassebunk.dk/2011/09/03/getting-your-assets-to-work-when-upgrading-to-rails-3-1/

And Here: http://railsmonkey.net/2011/08/deploying-rails-3-1-applications-with-capistrano/

And here: http://dev.af83.com/2011/09/30/capistrano-rails-3-1-assets-can-be-tricky.html

Here is my deploy.rb :

require "bundler/capistrano"
load 'deploy/assets'

set :default_environment, {
 'PATH' => "/opt/ruby/bin/:$PATH"
}

set :application, "tomahawk"
set :repository,  "repo_goes_here"
set :deploy_to, "/home/deploy/#{application}"
set :rails_env, 'production'
set :branch, "master"

set :scm, :git
set :user, "deploy"
set :runner, "deploy"
set :use_sudo, true

role :web, "my_ip"                         
role :app, "my_ip"                        
role :db,  "my_ip", :primary => true 

set :normalize_asset_timestamps, false
after "deploy", "deploy:cleanup"

namespace :deploy do
    desc "Restarting mod_rails with restart.txt"
    task :restart, :roles => :app, :except => { :no_release => true } do
        run "touch #{current_path}/tmp/restart.txt"
    end

    [:start, :stop].each do |t|
        desc "#{t} task is a no-op with mod_rails"
        task t, :roles => :domain do ; end
    end
end

task :after_update_code do  
run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
end

Solution

  • I later noticed that capistrano wasn't able to delete old releases, I got an error:

    *** [err :: ip_address] sudo: no tty present and no askpass program specified
    

    I found this link regarding this error: http://www.mail-archive.com/[email protected]/msg07323.html

    I had to add this line to my deploy file:

    default_run_options[:pty] = true
    

    This also solved the weird error I was getting above.

    The official explanation, which I don't understand :)

    No default PTY. Prior to 2.1, Capistrano would request a pseudo-tty for each command that it executed. This had the side-effect of causing the profile scripts for the user to not be loaded. Well, no more! As of 2.1, Capistrano no longer requests a pty on each command, which means your .profile (or .bashrc, or whatever) will be properly loaded on each command! Note, however, that some have reported on some systems, when a pty is not allocated, some commands will go into non-interactive mode automatically. If you’re not seeing commands prompt like they used to, like svn or passwd, you can return to the previous behavior by adding the following line to your capfile: default_run_options[:pty] = true