Rails 4, Capistrano 3 fail during bundle exec rake assets:precompile and returns rake stdout: Nothing
Asked Answered
S

1

7

Deploying with Capistrano fail during rake assets:precompile:

/usr/local/rvm/bin/rvm ruby-2.0.0-p353 do bundle exec rake assets:precompile

The Prompt Respond with this error:

INFO [b438501f] Running /usr/local/rvm/bin/rvm ruby-2.0.0-p353 do bundle exec rake assets:precompile on 123.123.123.123

cap aborted!
rake stdout: Nothing written
rake stderr: Nothing written
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:164:in `block (2 levels) in _execute'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:166:in `block in _execute'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/capistrano-rails-1.1.1/lib/capistrano/tasks/assets.rake:59:in `block (6 levels) in <top (required)>'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:89:in `with'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/capistrano-rails-1.1.1/lib/capistrano/tasks/assets.rake:58:in `block (5 levels) in <top (required)>'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:81:in `within'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/capistrano-rails-1.1.1/lib/capistrano/tasks/assets.rake:57:in `block (4 levels) in <top (required)>'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/osiris/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Command::Failed: rake stdout: Nothing written
rake stderr: Nothing written
>

Here my debloy.rb

# config valid only for Capistrano 3.1
lock '3.1.0'

set :application, 'Myapp'
set :repo_url, '[email protected]:randomuser/myapp.git'

set :deploy_to, '/var/www/myapp'

set :rvm_ruby_version, 'ruby-2.0.0-p353'

set :log_level, :info

set :linked_files, %w{config/database.yml}

set :keep_releases, 20

# SSHKit.config.output_verbosity = :debug
SSHKit.config.output = $stdout
SSHKit.config.output_verbosity = Logger::DEBUG
SSHKit.config.command_map[:rake] = "bundle exec rake"
SSHKit.config.command_map[:rails] = "bundle exec rails"

set :normalize_asset_timestamps, %{public/images public/javascripts public/stylesheets}

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

  after :finishing, "deploy:cleanup"
end

You can find more details about this issue on this Gist: https://gist.github.com/richardsondx/10092890 I noticed that the environment is not mentioned in the rake task even though I mentioned it in production.rb. It could help to overwrite the prefix the command with RAILS_ENV=production

I tried to overwrite the task with:

namespace :deploy do

  namespace :assets do
    task :precompile do
      on roles(fetch(:assets_roles)) do
        within release_path do
          with rails_env: fetch(:rails_env) do
            execute :rake, "assets:precompile RAILS_ENV=production"
          end
        end
      end
    end
  end
end

But it didn't overwrite it.

Sulph answered 8/4, 2014 at 6:50 Comment(4)
try precompile assets in your local box, it's possible that you have errors in your sass or coffee/js filesCanonicity
Which gem are you using for the management of rvm with Capistrano ? If you're using capistrano-rvm, I think, changing it to rvm1-capistrano3 should help.Niles
I had to up the ram on my VPS to 1G to compile assets.Walkerwalkietalkie
Should worth a try? with rails_env: :production doTerrilynterrine
P
25

I was dealing with the same problem in my VPN on DigitalOcean and I had to create the swap memory. My VPS was killing the assets precompile process.

Before creating swap memory, you can check if your server is using some swap memory using htop. My server wasn't ...

Try this:

  • Create 1GB swap memory sudo dd if=/dev/zero of=/usr/mem.swap bs=1M count=512

  • Use the swap memory created in the first step sudo mkswap /usr/mem.swap sudo swapon /usr/mem.swap

Pug answered 15/7, 2014 at 2:1 Comment(4)
This helps a lot, I saw this answer today, and could u explan the reason to this? AndInfantry
Hi! some VPN hosts doesn't have the swap memory enabled... unfortunately I don't know why. =/Pug
for me swap was too smallThanks
Thank you Sagar Ranglani =DPug

© 2022 - 2024 — McMap. All rights reserved.