1

I have an existing rails app in Heroku and I'm trying to push it there but it gives me this error everytime I try to push to Heroku

There was an error parsing your Gemfile, we cannot continue
remote:  !     /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
remote:  !     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
remote:  !     from /tmp/d20190617-88-bonyg7/bundler-2.0.1/bin/bundle:23:in `<main>'

From there, what I think stands out the most are:

There was an error parsing your Gemfile, we cannot continue
can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

My Gemfile.lock states that my app is bundled with 2.0.2

When I do gem list, bundler part gives me this bundler (default: 2.0.2, default: 1.17.2)

Any help is appreciated! Thanks!

EDIT: Here is my Gemfile

source 'https://rubygems.org'
ruby '2.6.3'

gem 'bootsnap', require: false
gem 'devise'
gem 'jbuilder', '~> 2.0'
gem 'pg', '~> 0.21'
gem 'puma'
gem 'rails', '5.2.3'
gem 'redis'

gem 'autoprefixer-rails'
gem 'font-awesome-sass', '~> 5.6.1'
gem 'sassc-rails'
gem 'simple_form'
gem 'uglifier'
gem 'webpacker'
gem 'bundler'

gem 'material-sass', '4.1.1'

gem 'cloudinary'
gem 'carrierwave'

group :development do
  gem 'web-console', '>= 3.3.0'
end

group :development, :test do
  gem 'pry-byebug'
  gem 'pry-rails'
  gem 'listen', '~> 3.0.5'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'dotenv-rails'
end
domosaurus
  • 345
  • 1
  • 4
  • 10
  • 4
    Possible duplicate of [find\_spec\_for\_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)](https://stackoverflow.com/questions/47026174/find-spec-for-exe-cant-find-gem-bundler-0-a-gemgemnotfoundexception) – Deepak Mahakale Jun 17 '19 at 16:49
  • Can you post your `Gemfile` please. – danielavila Jun 17 '19 at 17:29
  • @DeepakMahakale I tried `gem update --system` then `bundle install`, deleting `Gemfile.lock`, and `gem install bundler -v 2.0.2`. None worked, sadly. – domosaurus Jun 17 '19 at 18:25
  • @danielavila Edited to add `Gemfile` – domosaurus Jun 17 '19 at 18:26
  • Heroku's help section has a relevant post https://help.heroku.com/FKWXVZLA/error-parsing-your-gemfile-can-t-find-gem-bundler-0-a – supremebeing7 Jun 17 '19 at 21:49
  • Is your app already up on heroku from a previous deploy? If so, you can run `heroku run bash` to ssh to your heroku machine and run `bundle -v` to see what version of bundler is installed. Then you can install that specific version of bundler locally and redo the `bundle install` so your `Gemfile.lock` reflects that. – supremebeing7 Jun 17 '19 at 21:58
  • @supremebeing7 yes it was already deployed before, I just moved to a new machine and added the remote to it. I did what you said and it still does not work, sadly. I made a new project to see whether the problem was project specific but it was not, I made a brand new rails app and it does not work there as well, and it produced the same error – domosaurus Jun 18 '19 at 00:49
  • I just noticed, heroku is trying to run bundler for a different ruby version: `heroku-18/lib/ruby/2.5.0/rubygems.rb:308:in 'activate_bin_path'`. I think the problem is definitely a version mismatch between your local env and heroku, likely with ruby, bundler, or both. – supremebeing7 Jun 18 '19 at 15:21
  • This might also help https://stackoverflow.com/a/54088849/3477163 – supremebeing7 Jun 18 '19 at 15:23

1 Answers1

2

The issue here is that Heroku is unable to use the bundle that you are requesting him to use. You can fix it with many solutions while you request Heroku to use a bundle they know (As I know, 2.0.2 does not work).

Opening your Gemfile.lock and at the end of the file replace

BUNDLED WITH
2.0.2

with

BUNDLED WITH
2.0.1

To fix the issue on the long term you can just gem uninstall bundler and then run gem install bundler -v 2.0.1