将 Rails 6 应用程序部署到 Elastic Beanstalk 时出现 Bundler 错误
Posted
技术标签:
【中文标题】将 Rails 6 应用程序部署到 Elastic Beanstalk 时出现 Bundler 错误【英文标题】:Bundler error when deploying Rails 6 App to Elastic Beanstalk 【发布时间】:2020-03-07 10:19:24 【问题描述】:在部署到 Heroku 和 AWS Elastic Beanstalk 时,我一直在努力解决众所周知的 bundler 2.0.x
错误。在尝试了许多建议的补救措施后,例如更新 gems 和安装 bundler 2.0.x 或 bundler update --system
。到目前为止,这些都没有奏效。我找到了在.ebextensions
中创建文件的解决方案,如下所示:
files:
# Runs before \./10_bundle_install.sh`:`
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_gem_install_bundler.sh" :
mode: "000775"
owner: root
group: users
content: |
#!/usr/bin/env bash
EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
# Source the application's ruby, i.e. 2.6. Otherwise it will be 2.3, which will give this error: \bundler requires Ruby version >= 2.3.0``
. $EB_SCRIPT_DIR/use-app-ruby.sh
cd $EB_APP_STAGING_DIR
echo "Installing compatible bundler"
gem install bundler -v 2.1.0.pre.2
这是我在eb deploy staging-1
上仍然遇到的错误:
Creating application version archive "app-7b50-191111_122622".
Uploading: [##################################################] 100% Done...
2019-11-11 17:28:21 INFO Environment update is starting.
2019-11-11 17:28:28 INFO Deploying new version to instance(s).
2019-11-11 17:31:36 ERROR [Instance: i-0ba40e32901557bee] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ystem, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.0.pre.2`
from /opt/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems.rb:303:in `activate_bin_path'
from /opt/rubies/ruby-2.6.5/bin/bundle:23:in `<main>'.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2019-11-11 17:31:36 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2019-11-11 17:31:36 ERROR Unsuccessful command execution on instance id(s) 'i-0ba40e32901557bee'. Aborting the operation.
2019-11-11 17:31:37 ERROR Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.
[12:31:40] (master) tml_portal
// ♥ eb deploy staging-1
Creating application version archive "app-7b50-191111_123229".
Uploading: [##################################################] 100% Done...
2019-11-11 17:34:45 INFO Environment update is starting.
2019-11-11 17:34:53 INFO Deploying new version to instance(s).
2019-11-11 17:37:47 ERROR [Instance: i-0ba40e32901557bee] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ystem, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.0.pre.2`
from /opt/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems.rb:303:in `activate_bin_path'
from /opt/rubies/ruby-2.6.5/bin/bundle:23:in `<main>'.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2019-11-11 17:37:47 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2019-11-11 17:37:47 ERROR Unsuccessful command execution on instance id(s) 'i-0ba40e32901557bee'. Aborting the operation.
2019-11-11 17:37:48 ERROR Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.
关于如何解决这个可怕的 Bundler 部署问题的任何想法?
【问题讨论】:
运气好吗?我遇到了类似的错误... 【参考方案1】:它仍然缺少捆绑版本错误。您可以尝试以下操作吗:
#.ebextensions/bundler_update.config
commands:
update_bundler:
command: /opt/rubies/ruby-2.6.5/bin/gem install bundler -v 2.1.0.pre.2
Ruby 和 Bundler 版本应该与您的匹配。
【讨论】:
谢谢。我已经尝试过了,但仍然没有运气。看到我在截止日期前部署应用程序(这是一个新应用程序),很想与某人进行实时聊天。以上是关于将 Rails 6 应用程序部署到 Elastic Beanstalk 时出现 Bundler 错误的主要内容,如果未能解决你的问题,请参考以下文章
AWS Elastic Beanstalk Ruby on Rails 6 应用程序部署错误与 nginx
将 Rails + Puma + Postgres 应用程序部署到 Elastic beanstalk 的正确方法?
无法将 Rails API 应用程序部署到 AWS Elastic Beanstalk