Deploying on Heroku, how to specify ruby version to use for bundler?


Something has changed recently on Heroku. I can't deploy my app as I've done before:

me@host my-project (master) $ git push staging master
Counting objects: 52, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (52/52), 159.47 KiB | 0 bytes/s, done.
Total 52 (delta 42), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: -----> Deleting 4 files matching .slugignore patterns.
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.0
remote: -----> Installing dependencies using bundler 1.13.6
remote:        Your app was upgraded to bundler 1.13.6.
remote:        Previously you had a successful deploy with bundler 1.11.2.
remote:        If you see problems related to the bundler version please refer to:
remote:        Ruby version change detected. Clearing bundler cache.
remote:        Old: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
remote:        New: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Your Ruby version is 2.3.0, but your Gemfile specified 2.2.0
remote:        Bundler Output: Your Ruby version is 2.3.0, but your Gemfile specified 2.2.0
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:  !     Push failed
remote: Verifying deploy...
remote: ! Push rejected to my-project-staging.
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to ''

I don't get it, i'm using ruby 2.2.0 since the beginning:

me@host my-project (master) $ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]

me@host my-project (master) $ cat .ruby-version 

me@host my-project (master) $ cat Gemfile | grep 'ruby'
ruby '2.2.0'

I don't know how to tell bundler I'm still using ruby 2.2.0. My bundler have this in the bottom:

   ruby 2.3.0p0


Why bundler doesn't use the ruby 2.2.0 version? It's using 2.3.0 instead...

Show source
| ruby   | heroku   | bundler   | gemfile   | heroku-toolbelt   2016-11-18 09:11 2 Answers

Answers ( 2 )

  1. 2016-11-18 12:11

    Check your Gemfile.lock. Recent versions of bundler add both the ruby version and bundler version that were used install the gems (and generate the Gemfile.lock).

    At the bottom you'll find:

       ruby 2.3.0 
       1.13.1 # or whatever version of bundler you're using

    Remove this, and re-run bundle install with the correct version of ruby - you may need to remove + re-add a gem to trigger a re-build of the Gemfile.lock file.

  2. 2016-11-22 01:11

    Finally I add to remove bundler and install the same version as Heroku.

◀ Go back