简体   繁体   English

尝试将更新的 Rails 应用程序部署到 Heroku 时出错 - /bin/bundle:无法执行二进制文件:执行格式错误

[英]Error when trying to deploy updated Rails app to Heroku - /bin/bundle: cannot execute binary file: Exec format error

I have a previously deployed Ruby on Rails API that I wanted to add some additional seed data to.我之前在 Rails API 上部署了 Ruby,我想向其中添加一些额外的种子数据。

I am getting the following error when I deploy from either the Heroku CLI or from the web interface:从 Heroku CLI 或 web 界面部署时,我收到以下错误:

-----> 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部署到全新的 Heroku 应用程序
  • Adding a Procfile添加 Procfile
  • Adding a Ruby build pack添加 Ruby 构建包
  • 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通过在本地运行 Bundle update 并将新的 gemfile 放入我的 repo 来解决来自 Github 的一些突出的安全警告,在此之前没有新的 Gem 更改

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.如果我将 github 中的存储库克隆到我的 Macbook 上的新文件夹中,我可以在本地启动并运行它。

I have the following on my Macbook:我的 Macbook 上有以下内容:

  • Ruby Version 2.6.5p114 Ruby 版本 2.6.5p114
  • Rails Version 6.0.3.2导轨版本 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.除了对 CPU 架构的一些引用之外,谷歌似乎并没有出现太多,我认为我在 Heroku 环境中无法控制。

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.我的感觉是它与 bash 无法执行 bin/bundle 有关,但我不知道为什么或如何解决。

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我隐约记得以前在这个应用程序上遇到过问题,因为我无法运行heroku run rake命令,可能会收到类似的错误消息,但要解决,我想我可以简单地运行heroku run bin/rake

I believe the original rails new command was run on Windows 10 WSL environment in case that is relevant.我相信原始rails new命令是在 Windows 10 WSL 环境中运行的,以防万一。

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.编辑:我可以用rake重新创建一个类似的问题,但是rake的修复对bundle不起作用,我什至不确定它是否有助于解决部署问题。

➜  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

Turns out it was exactly as the error message stated Exec format error .原来它与错误消息中所说的Exec format error完全一样。

The bundle file in the bin directory was not the right format. bin 目录中的捆绑文件格式不正确。 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).不知道我是如何设法部署的(这个文件的历史在 repo 中只有 2 个版本,第一次提交,现在是修复)。

I was able to resolve by overwriting the bundle file from a different working rails install.我能够通过覆盖来自不同工作导轨安装的捆绑文件来解决。 Appreciated the help provided.感谢提供的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM