0

I have a previously deployed Ruby on Rails API that I wanted to add some additional seed data to.

I am getting the following error when I deploy from either the Heroku CLI or from the web interface:

-----> Ruby app detected
-----> Installing bundler 2.0.2
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.6.5
-----> Installing dependencies using bundler 2.0.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       bash: /tmp/build_9062c7d5995d7f7c573d9509eb8f19d5/bin/bundle: cannot execute binary file: Exec format error
       Bundler Output: bash: /tmp/build_9062c7d5995d7f7c573d9509eb8f19d5/bin/bundle: cannot execute binary file: Exec format error
 !
 !     Failed to install gems via Bundler.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

I am not sure what the issue is. I have tried:

  • Deploying to a brand new Heroku application
  • Adding a Procfile
  • Adding a Ruby build pack
  • Resolving some outstanding security warnings from Github by running Bundle update locally and getting the new gemfile into my repo, prior to this there were no new Gem changes

None of these has changed the error I am getting.

If I clone the repo from github into a new folder on my Macbook I am able to get it up and running locally.

I have the following on my Macbook:

  • Ruby Version 2.6.5p114
  • Rails Version 6.0.3.2

Google does not seem to be turning up much, aside from some references to CPU architecture which I assume I have no control of in the Heroku environment.

My feeling is that it is related to bash being unable to execute bin/bundle but I've no idea why or how to resolve.

I vaguely recall having issues previously on this app, in that I was not able to run heroku run rake commands, possibly getting a similar error message, but to resolve I think I was able to simply run heroku run bin/rake

I believe the original rails new command was run on Windows 10 WSL environment in case that is relevant.

EDIT: I'm able to recreate a similar issue with rake, but the fix for rake does not work for bundle and I'm not even sure if it would help with the deployment issue.

➜  appbackend git:(master) heroku run rake
Running rake on ⬢ heroku-name-40049... up, run.8396 (Hobby)
bash: /app/bin/bundle: cannot execute binary file: Exec format error
➜  appbackend git:(master) heroku run bin/rake
Running bin/rake on ⬢ heroku-name-40049... up, run.5201 (Hobby)
Abort testing: Your Rails environment is running in production mode!
➜  appbackend git:(master) 

➜  appbackend git:(master) heroku run bundle install
Running bundle install on ⬢ heroku-name-40049... up, run.7746 (Hobby)
bash: /app/bin/bundle: cannot execute binary file: Exec format error
➜  appbackend git:(master) heroku run bin/bundle install
Running bin/bundle install on ⬢ heroku-name-40049... up, run.4632 (Hobby)
bash: bin/bundle: cannot execute binary file: Exec format error
  • Does [this question](https://stackoverflow.com/questions/4574176/heroku-push-rejected-failed-to-install-gems-via-bundler) help you? The answers mostly centre on doing a local ``bundle update``, ensuring latest ``Gemfile.lock`` is checked into the repo, and repushing. – rmlockerd Jul 14 '20 at 01:46
  • check this https://stackoverflow.com/questions/22017128/heroku-deployment-fails-during-bundle-install – nourza Jul 14 '20 at 02:38
  • @rmlockerd I just tried running bundle update and it looks like I am already fully up to date, which I think is due to doing similar to resolve the github warnings. – gullwings13 Jul 14 '20 at 02:56
  • @nourza I'm not seeing any unterminated strings in my gemfile and my error message looks a little different from the linked one (no mention of unterminated strings in mine) – gullwings13 Jul 14 '20 at 03:03
  • @gullwings13 whats the result of bundle update? – nourza Jul 14 '20 at 03:04
  • Try to run this: bundle; git add -f Gemfile.lock; git commit -am "add gemfile.lock"; git push heroku master – nourza Jul 14 '20 at 03:06
  • @nourza it runs through, but the gemfile and the gemfile.lock are unchanged. This is because I had done this bundle update and committed the updated gemfile and gemfile.lock to my master branch already to resolve the github warnings and this did not help resolve the issue. – gullwings13 Jul 14 '20 at 03:07
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/217769/discussion-between-gullwings13-and-nourza). – gullwings13 Jul 14 '20 at 03:10
  • The odd part is that an ``Exec format error`` is what you get when you run a binary that's built for another architecture. I'm struggling to come up with a plausible reason that's in your control in this case. – rmlockerd Jul 14 '20 at 03:19
  • I am able to recreate the previous issue I had with rake, however I'm not able to 'resolve' it for bundle. I've edited the original post to show the results of doing so. – gullwings13 Jul 14 '20 at 03:48

1 Answers1

0

Turns out it was exactly as the error message stated Exec format error.

The bundle file in the bin directory was not the right format. Not sure how I managed to deploy in the first place (the history of this file has only 2 version in the repo, the first commit, and now the fix).

I was able to resolve by overwriting the bundle file from a different working rails install. Appreciated the help provided.