简体   繁体   English

将 Rails 6 应用程序部署到 Elastic Beanstalk 时出现 Bundler 错误

[英]Bundler error when deploying Rails 6 App to Elastic Beanstalk

I've been struggling getting around the well known bundler 2.0.x error when deploying to both Heroku and AWS Elastic Beanstalk.在部署到 Heroku 和 AWS Elastic Beanstalk 时,我一直在努力解决众所周知的bundler 2.0.x错误。 After trying many of the suggested remedies like updating gems and installing bundler 2.0.x or bundler update --system .在尝试了许多建议的补救措施后,例如更新 gems 和安装 bundler 2.0.x 或bundler update --system None of this has worked so far.到目前为止,这些都没有奏效。 I found a solution to create a file in .ebextensions like so:我找到了一个在.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

This is the error I'm still getting on eb deploy staging-1 :这是我在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.

Any ideas on how to get around this dreaded Bundler issue for deployment?关于如何解决这个可怕的 Bundler 部署问题的任何想法?

It still the missing bundle version error.它仍然缺少捆绑版本错误。 Could you try following:您可以尝试以下操作:

#.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 and Bundler version should match yours. Ruby 和 Bundler 版本应该与您的匹配。

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

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