Precompiling assets with Capistrano 3.0.1

For some reason Capistrano 3.0.1 runs rake assets:precompile instead of bundle exec rake assets:precompile. This may cause issues if you have multiple versions of gems installed on your server. I was running into this error.

rake aborted!
You have already activated rake 0.9.6, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this.

After a bit of googling I found this workaround.

So I added this line to the top of my config/deploy.rb file

SSHKit.config.command_map[:rake] = "bundle exec rake"

and I’m back in business.

Huzzah!

Comments

    Caleb |

    Nice!

    Lee Jackson |

    Thank you :)

    Alexandr Korsak |

    Also it’s possible to use capistrano-bundler gem and define bundled commands like:

    require ‘capistrano/bundler’
    set :bundle_bins, %w(gem rake rails sidekiq your_binary_to_run)