Search code examples
rubyherokusinatraheroku-postgres

How do I fix a Bundler Conflict when pushing to Heroku?


I'm attempting to deploy a Sinatra app to Heroku. Everything works locally. However I get an issue with bundler when I try to push it successfully to Heroku.

I've tried to delete the Gemfile lock and then the following

bundle update
git add .
git push "Gemfile.lock"
git push heroku master
gem install bundler:2.0.1
bundle install
git add .
git push "Gemfile.lock"
git push heroku master
bundle update --bundler
git add .
git push "Gemfile.lock"
git push heroku master

Here is my gemfile

source "https://rubygems.org"

# gem "rails"
gem 'sinatra'
gem 'activerecord', '~> 5.2', '>= 5.2.2.1'
gem 'rake'
gem 'sinatra-activerecord'
gem 'require_all'
gem 'bcrypt'
gem 'rack-flash3'
gem 'rb-readline'

group :development, :test do
 gem 'sqlite3'
 gem 'shotgun'
 gem 'pry'
end

group :production do
 gem 'pg'
end

Here are the error messages

remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rack
remote: -----> Using Ruby version: ruby-2.5.5
remote: -----> Installing dependencies using bundler 2.0.2
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Activating bundler (2.0.1) failed:
remote:        Could not find 'bundler' (2.0.1) required by your /tmp/build_77505ef74596fc4dddd66c8b792d759b/Gemfile.lock.
remote:        To update to the latest version installed on your system, run `bundle update --bundler`.
remote:        To install the missing version, run `gem install bundler:2.0.1`
remote:        Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information
remote:        
remote:        To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
remote:        Bundler Output: Activating bundler (2.0.1) failed:
remote:        Could not find 'bundler' (2.0.1) required by your /tmp/build_77505ef74596fc4dddd66c8b792d759b/Gemfile.lock.
remote:        To update to the latest version installed on your system, run `bundle update --bundler`.
remote:        To install the missing version, run `gem install bundler:2.0.1`
remote:        Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information
remote:        
remote:        To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`
remote: 
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to infinite-waters-69714.
remote: 
To https://git.heroku.com/infinite-waters-69714.git
 ! [remote rejected] master -> master (pre-receive hook declined)

Additionally, I've tried to remove sqlite3 altogether and repeat the above processes.

Any ideas on how to fix this?


Solution

  • I've ran into this issue some time ago: I contacted Heroku and they told me they have a locked version of Bundler, so your only option is to use the Bundler version they use:

    gem uninstall bundler
    gem install bundler -v 2.0.2
    bundle update