Heroku push rejected, failed to install gems via Bundler

Ruby on-RailsRubygemsHerokuRuby on-Rails-3Bundler

Ruby on-Rails Problem Overview


I am struggling to push my code to Heroku. And after searching on Google and Stack Overflow questions, I have not been able to find the solution. Here is What I get when I try "git push heroku master" :

Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
       Installing rails3_serve_static_assets... done
-----> Gemfile detected, running Bundler version 1.0.3
       Unresolved dependencies detected; Installing...
       Fetching source index for http://rubygems.org/
       /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:300:in `open_uri_or_path': bad response Not Found 404 (http://rubygems.org/quick/Marshal.4.8/mail-2.2.6.001.gemspec.rz) (Gem::RemoteFetcher::FetchError)
       	from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:172:in `fetch_path'
.
....

And finally:

FAILED: http://docs.heroku.com/bundler
 !     Heroku push rejected, failed to install gems via Bundler

error: hooks/pre-receive exited with error code 1
To [email protected]:myapp.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:myapp.git'

Thanks for your help!

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

I don't think it's a Rails version problem, nor is it specific to Heroku. (I hit the same problem today, when running bundle install on my local development machine, with Rails 3.0.3.)

Running bundle update locally, as Andrew suggested, fixes the issue.

Edit: As suggested in the comments: remember to git add . , git commit -m "message"

Solution 2 - Ruby on-Rails

I have same issue: remote: ! Failed to install gems via Bundler.

if you see the problem is this:

remote:  Your bundle only supports platforms ["x86_64-darwin-16"] but your local platform
remote:  is x86_64-linux. Add the current platform to the lockfile with `bundle  loc
remote:  --add-platform x86_64-linux` and try again.

its mean this :

Your bundle only supports platforms ["x86_64-darwin-16"] but your local platform is x86_64-linux. Add the current platform to the lockfile with `bundle loc --add-platform x86_64-linux` and try again.

If you see in your gemfile.loc you only have this :

PLATFORMS
  x86_64-darwin-16

So I did this command, To add in your platform in gemfile.loc

bundle lock --add-platform x86_64-linux

This will update your Gemfile.loc :

PLATFORMS
  x86_64-darwin-16
  x86_64-linux

Continue :

git add .
git commit -m "add platform x86_64-linux"

Push again

git push heroku master:main

Solve!

Solution 3 - Ruby on-Rails

I solved this issue this way:

  1. bundle update
  2. git add Gemfile.lock
  3. git commit -m 'Update Gemfile.lock for Heroku'
  4. git push heroku master

Solution 4 - Ruby on-Rails

bundle lock --add-platform ruby
bundle lock --add-platform x86_64-linux
bundle install
git add .
git commit -m "Bundler fix"

Solution 5 - Ruby on-Rails

Another tip: Open your Gemfile.lock and check if this block exists:

PLATFORMS
  x86_64-darwin-20

If it exists, run the following command: bundle config force_ruby_platform true

Now, you must recreate the whole Gemfile.lock, because some gems can be builded just for MacOS. So, just remove the Gemfile.lock and run bundle install (do no forget to stop spring, if it's running, otherwise spring automatically recreates the Gemfile.lock file)

Solution 6 - Ruby on-Rails

Use:

rm -rf ~/.bundle/ ~/.gem/ .bundle/ Gemfile.lock

I had Gemfile.lock at my localserver make sure to delete it from the localserver AND also the HEROKU V-machine.

Solution 7 - Ruby on-Rails

  1. bundle update
  2. git add Gemfile.lock
  3. git commit -m 'Update Gemfile.lock for Heroku'
  4. git push heroku master

it worked for me.

Solution 8 - Ruby on-Rails

Run: bundle lock --add-platform x86_64-linux

  1. bundle update
  2. git add Gemfile.lock
  3. git commit -m 'Update Gemfile.lock for Heroku'
  4. git push heroku master

Solution 9 - Ruby on-Rails

I'm pretty sure Heroku only supports certain versions of Rails, so you need to be on at least 3.0, instead of a release candidate. Update the version of Rails in your gemfile, run bundle update, and then try to push to Heroku.

Solution 10 - Ruby on-Rails

I get the same - 404:

curl -v -I http://rubygems.org/quick/Marshal.4.8/mail-2.2.6.001.gemspec.rz

In your Gemfile you could try specifying a lower version number of this gem? 2.2.5 perhaps?

Solution 11 - Ruby on-Rails

I actually solved it by simply pushing it up a second time after letting things sit for a few minutes... I have re-spun my dokku system from scratch and encountered the same issue, on the same day after I had previously attempted a workaround of updating nokogiri. That was when I realized, this seems to be an oddity of herokuish; it doesn't always take on the first push.

I wonder if behind the scenes it's installing library headers, and when they take too long, bundler simply fails the install.

Solution 12 - Ruby on-Rails

My problem was about pg gem.

After installing postgres with 'brew install postgres' bundling finished.

Then doing commands Dyo Medio described, I managed to deploy the app on Heroku.

Solution 13 - Ruby on-Rails

I was able to overcome this very issue today by purging the cache with steps (and was told it has to be done with each deployment until the bug is found and squashed): First install the plugin:

  heroku plugins:install heroku-builds

Then use the following command to clear the cache:

  heroku builds:cache:purge -a example-app

The cache will be rebuilt on the next deploy. If you do not have any new code to deploy, you can push an empty commit.

  $ git commit --allow-empty -m "Purge cache"
  $ git push heroku master

Where example-app is replaced by the name of the app you want to clear the cache for.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionismaelsowView Question on Stackoverflow
Solution 1 - Ruby on-RailsJacobView Answer on Stackoverflow
Solution 2 - Ruby on-RailsDyo MedioView Answer on Stackoverflow
Solution 3 - Ruby on-RailsRoman KrasavtsevView Answer on Stackoverflow
Solution 4 - Ruby on-RailsamarimonView Answer on Stackoverflow
Solution 5 - Ruby on-RailsJon MacielView Answer on Stackoverflow
Solution 6 - Ruby on-RailsEranView Answer on Stackoverflow
Solution 7 - Ruby on-RailsAyush JainView Answer on Stackoverflow
Solution 8 - Ruby on-RailsClaire Ann BayodaView Answer on Stackoverflow
Solution 9 - Ruby on-RailsAndrewView Answer on Stackoverflow
Solution 10 - Ruby on-RailsstefView Answer on Stackoverflow
Solution 11 - Ruby on-RailsNinjaxorView Answer on Stackoverflow
Solution 12 - Ruby on-RailsAhmet Firat KelerView Answer on Stackoverflow
Solution 13 - Ruby on-RailsTom ConnollyView Answer on Stackoverflow