0
votes

After installing a new gem, Slackistrano to already succesfully deployed app with Capistrano, our deployments started failing with the following error during rake assets:precompile or rake db:migrate tasks

cap aborted!
SSHKit::Command::Failed: rake stdout: Nothing written
rake stderr: Nothing written
/Users/pete/.rvm/gems/ruby-2.2.2/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='

This error is obviously not very helpful.

If I ran the capistrano task cap staging assets:precompile, it would succeed.

So what's going on here?

There are a few other solutions to SSHKit failures during cap deployments, but most of them were for first time deployments and didn't work for me.

1

1 Answers

0
votes

Here's how I figured out the solution(after much hair pulling).

I knew that it was probably the new gem that was causing the problem. So I went into the source code for sshkit/command.rb and outputted the command it was trying to execute on the remote server.

I then logged into the remote server and ran it manually and got the following output:

$ cd /home/web/sites/site.com/releases/20160106224143 && ( RAILS_ENV=production ~/.rvm/bin/rvm default do bundle exec rake db:migrate )
rake aborted!
NoMethodError: undefined method `each_pair' for "slack:deploy:updating":String
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1602:in `compile!'
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1344:in `add_filter'
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1331:in `before'
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1989:in `block (2 levels) in delegate'
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/slackistrano-1.0.0/lib/slackistrano/tasks/slack.rake:121:in `<top (required)>'

So, the problem started with Slackistrano, but then, what? why is Sinatra there? I don't use Sinatra in my app.

Well, I discovered that there was a gem in my Gemfile that was for development only(mailcatcher) but was in the production section of the Gemfile. I removed this and redeployed successfully.

However, there is obviously a deeper issue because there seems to be some sort of name collision on the "before" method of sinatra and capistrano that caused this in the first place.

I'm posting here to help others debug possible SSHKit errors during Cap deployments and also perhaps to guide others on weird name collisions between Sinatra and Capistrano.