noob
noob

Reputation: 1807

rails heroku asset precompile fail due to rake version

When I tried to push to heroku I get this msg:

rake aborted! undefined method empty? for nil:NilClass (in /tmp/build_3d16ad44-0015-4ecb-a7cf-a41959f03f82/app/assets/stylesheets/application.css.scss)

Upon tracing it, I realized that it's because

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

This may be a really dumb question, but I am not sure how I am supposed to use bundle exec to do this for heroku? Please help. Thanks.

Upvotes: 0

Views: 480

Answers (2)

noob
noob

Reputation: 1807

In case anyone else runs into a similar issue. The problem was that heroku was using ruby 2.0 with all their new apps so in order to do that you have to put whatever ruby version you are using on the gemfile then reset git by typing git reset --soft HEAD~ and then git reset HEAD public/assets into your command line. And rm -r public/assets if you have untracked files in public/assets. Then save the changes and push up to your new site.

So if your app uses an older version of ruby than 2.0, you will have to make similar changes until the bug (sprocket?) is fixed.

Upvotes: 2

Aman Garg
Aman Garg

Reputation: 4218

Inside the project directory in terminal:

gem list rake

You will see more than one version. If so, then remove the version you don't need (i.e. 10.0.3 in your case) by command:

gem uninstall rake

It will ask you specific version to select from list, choose one and press enter.

Or, you can also update to specific rake version

bundle update rake -v '0.9.2.2'

Upvotes: 0

Related Questions