elasticbeanstalk的捆绑安装错误

Posted

技术标签:

【中文标题】elasticbeanstalk的捆绑安装错误【英文标题】:bundle install error for elasticbeanstalk 【发布时间】:2021-12-28 22:52:22 【问题描述】:

我刚刚在我的 Gemfile 中添加了这个新的 Gem:gem 'pg_query',当我在本地运行 bundle install 时,一切正常。但是,当我尝试部署到 elasticbean stalk 时,我收到了这个以前没有遇到的错误:

2021/11/18 00:33:20.171799 [ERROR] An error occurred during execution of command [app-deploy] - [stage ruby application]. Stop running the command. Error: install dependencies in Gemfile failed with error Command /bin/sh -c bundle install failed with error exit status 1. Stderr:Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Your lockfile was created by an old Bundler that left some things out.
You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile.
The missing gems are:
* google-protobuf depended upon by pg_query

这是我的Gemfile.lock:https://pastebin.com/X9VqfFkK

这是我的Gemfile:https://pastebin.com/e9aBu9EQ

任何想法可能会发生什么?我觉得这与弹性豆茎有关,因为我过去在上面安装宝石时遇到过麻烦。

【问题讨论】:

如果您想解决这个问题,下一步似乎是更新 Bundler 和/或添加该依赖项。 嘿@JakeWorth,我不确定在这种情况下我应该更新什么以及更新到什么版本,如果你检查Gemfile.lock,依赖已经存在,所以不知道如何继续克服此错误以使部署再次工作。 尝试gem install bundler 并确保您使用的是最新版本(在撰写本文时为 v2.2.31,尽管我并不完全了解 Bundler 的版本控制是如何工作的)。然后运行bundle install 并确保该版本位于锁定文件的底部。如果这不起作用,请尝试删除锁定文件并重新生成它。 【参考方案1】:

看起来请求的 gem google-protobuf 仅包含在 macOS/Darwin 操作系统中。要将其包含在 Linux 系统的 Gemfile.lock 中,您需要在本地运行以下命令:

bundle lock --add-platform x86_64-linux

(我假设 Elastic Beanstalk 使用 Linux - 根据需要调整平台)

我的理解是,这适用于为特定平台编译版本的 gem。默认情况下,Bundler 不包含所有已知平台 - 因此,如果您的开发和部署环境不同,则添加适当的平台可确保进一步捆绑涵盖所有相关情况。

【讨论】:

这似乎没有改变Gemfile.lock 中的任何内容,是否应该添加/更改一些内容?这是整个输出:[11/18/21 3:06:42] ➜ git:(develop) bundle lock --add-platform x86_64-linux Writing lockfile to Gemfile.lock 嗯,是的,Gemfile.lock 中应该有一些变化。也许更新到新版本的 Bundler 会有所帮助?但是很高兴您找到了解决方案 - 请注意,捆绑程序以后对 Gemfile.lock 的更新可能会逆转您的手动更改。【参考方案2】:

对于将来可能遇到此问题的任何人,感谢@pat 指出这一点,看来解决方案是手动更改我的Gemfile.lock 中的这一行来自:

google-protobuf (3.19.1-x86_64-darwin)

到:

google-protobuf (3.19.1)

之后,部署工作,bundle install 也在本地工作!我的 elastic beanstalk 上的平台运行的是 Linux,所以我认为这是最初错误的原因之一。

【讨论】:

以上是关于elasticbeanstalk的捆绑安装错误的主要内容,如果未能解决你的问题,请参考以下文章

在 elasticbeanstalk 上安装 npm canvas - npm 安装错误

Rails - AWS(Elastic Beanstalk)部署,错误命令“git clone”

捆绑安装错误“安装 json (1.7.3) 时发生错误”

Postgres 错误 - 捆绑安装

错误捆绑安装-“mysql2”[重复]

安装奏鸣曲新闻捆绑作曲家错误