Search code examples
npmcapistranosshkit

Capistrano 3 useless error message


I'm trying to figure out what's wrong with this command when run via a capistrano task. It runs fine if i run it directly on the server:

desc 'Run npm install on remote server'
  task :npm_install do
    on roles(:app) do
      puts '**** NPM INSTALL ****'
      execute "cd /var/www/#{fetch(:application)}/current/hapi && NODE_ENV=#{fetch(:env)} npm install"
    end
  end

Error which doesn't help much

$ cap prod deploy:npm_install
**** NPM INSTALL ****
INFO [23ed2aa2] Running /usr/bin/env cd /var/www/myapp/current/hapi && NODE_ENV=prod npm install as [email protected]
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: cd /var/www/myapp/current/hapi && NODE_ENV=prod npm install exit status: 1
cd /var/www/myapp/current/hapi && NODE_ENV=prod npm install stdout: Nothing written
cd /var/www/myapp/current/hapi && NODE_ENV=prod npm install stderr: Nothing written

SSHKit::Command::Failed: cd /var/www/myapp/current/hapi && NODE_ENV=prod npm install exit status: 1
cd /var/www/myapp/current/hapi && NODE_ENV=prod npm install stdout: Nothing written
cd /var/www/myapp/current/hapi && NODE_ENV=prod npm install stderr: Nothing written

Tasks: TOP => deploy:npm_install
(See full trace by running task with --trace)

Is there any way to turn on helpful error messages or something for remote tasks running through capistrano?


Solution

  • This blog post or this SO answer should help you increase your debugging.

    This FAQ should help you understand why Capistrano acts differently than a normal SSH session.