繁体   English   中英

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

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

我之前在 Rails API 上部署了 Ruby,我想向其中添加一些额外的种子数据。

从 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

我不确定问题是什么。 我努力了:

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

这些都没有改变我得到的错误。

如果我将 github 中的存储库克隆到我的 Macbook 上的新文件夹中,我可以在本地启动并运行它。

我的 Macbook 上有以下内容:

  • Ruby 版本 2.6.5p114
  • 导轨版本 6.0.3.2

除了对 CPU 架构的一些引用之外,谷歌似乎并没有出现太多,我认为我在 Heroku 环境中无法控制。

我的感觉是它与 bash 无法执行 bin/bundle 有关,但我不知道为什么或如何解决。

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

我相信原始rails new命令是在 Windows 10 WSL 环境中运行的,以防万一。

编辑:我可以用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

原来它与错误消息中所说的Exec format error完全一样。

bin 目录中的捆绑文件格式不正确。 不知道我是如何设法部署的(这个文件的历史在 repo 中只有 2 个版本,第一次提交,现在是修复)。

我能够通过覆盖来自不同工作导轨安装的捆绑文件来解决。 感谢提供的帮助。

暂无
暂无

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

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