Search code examples
ruby-on-rails-3capistrano

Capistrano 3.1: rake assets precompile not working


I am new to Capistrano and trying to precompile the assets. after entering command cap production deploy my code is successfully deployed on the server,but my assets are not compiled.below is my deploy.rb file.

       #SSHKit.config.command_map[:rake] = "bundle exec rake"
# config valid only for Capistrano 3.1
lock '3.1.0'

set :application, 'woi'
set :repo_url, '[email protected]:sanjay-salunkhe/cap.git'
set :branch, "master"
set :deploy_via, :remote_cache
set :stages, ["production"]

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

# Default deploy_to directory is /var/www/my_app
 set :deploy_to, '/home/webuser/apps/cap/'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
 set :keep_releases, 5

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
       execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :publishing, :restart

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end


  desc 'precompiling assets..............'
  task :composer_install do
    on roles(:web) do
      within release_path do
        execute :rake, "assets:precompile RAILS_ENV=production"
      end
    end
  end

  after :publishing, 'deploy:composer_install'



end

Below are my logs

   DEBUG [cf204b99]     /usr/bin/env: 
DEBUG [cf204b99]    rake
DEBUG [cf204b99]    : No such file or directory
DEBUG [cf204b99]    
cap aborted!
SSHKit::Command::Failed: rake stdout: Nothing written
rake stderr: Nothing written
/var/lib/gems/1.9.1/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/var/lib/gems/1.9.1/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _exe

also if possible then please send me the good documentation link for Capistrano 3.1.

Thanks,


Solution

  • Finally i manged to deploy my app using capastrano 3.Actually i had not included below two lines in my capfile.

     require 'capistrano/rvm'
    require 'capistrano/rails'
    

    After including these two lines my issue has been resolved.