有没有办法修复弹性豆茎中的Gem::LoadError [英] Is there a way to fix Gem::LoadError in Elastic Beanstalk

查看:19
本文介绍了有没有办法修复弹性豆茎中的Gem::LoadError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对弹性豆茎比较陌生,因此希望得到一些建议。在64位Amazon Linux上运行Ruby2.6的EB-Puma中部署RoR应用程序后,当我"转到环境"链接时,它没有呈现我的应用程序。尽管已通过CLI成功部署,但运行状况更改为已降级,并显示以下消息:

50.0 % of the requests to the ELB are failing with HTTP 5xx. Insufficient request rate (1.0 requests/min) to determine application health (5 minutes ago)

检查日志后,我找到了Gem::LoadError

/opt/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/bundler/runtime.rb:312:in `check_for_activated_spec!': You have already activated rack 1.6.8, but your Gemfile requires rack 2.2.3. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

这是我的Gemfile:

    source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.6'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4'
# Use Puma as the app server
gem 'puma', '~> 4.1', groups: [:development, :test]
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

gem 'font-awesome-sass'

#Devise Gem
gem 'devise'

#Pundit Gem
gem 'pundit'

gem "chartkick"

#Install figaro to manage local environment variables. Read more https://github.com/laserlemon/figaro
gem 'figaro'

#Install uickbooks ruby gem. Read more https://github.com/ruckus/quickbooks-ruby
gem 'quickbooks-ruby'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'prawn'
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
gem 'xero-ruby'
gem 'sassc', '~> 2.1.0'

我的Gemfile.lock如下所示:

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (6.0.3.5)
      actionpack (= 6.0.3.5)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailbox (6.0.3.5)
      actionpack (= 6.0.3.5)
      activejob (= 6.0.3.5)
      activerecord (= 6.0.3.5)
      activestorage (= 6.0.3.5)
      activesupport (= 6.0.3.5)
      mail (>= 2.7.1)
    actionmailer (6.0.3.5)
      actionpack (= 6.0.3.5)
      actionview (= 6.0.3.5)
      activejob (= 6.0.3.5)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (6.0.3.5)
      actionview (= 6.0.3.5)
      activesupport (= 6.0.3.5)
      rack (~> 2.0, >= 2.0.8)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.2.0)
    actiontext (6.0.3.5)
      actionpack (= 6.0.3.5)
      activerecord (= 6.0.3.5)
      activestorage (= 6.0.3.5)
      activesupport (= 6.0.3.5)
      nokogiri (>= 1.8.5)
    actionview (6.0.3.5)
      activesupport (= 6.0.3.5)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.1, >= 1.2.0)
    activejob (6.0.3.5)
      activesupport (= 6.0.3.5)
      globalid (>= 0.3.6)
    activemodel (6.0.3.5)
      activesupport (= 6.0.3.5)
    activerecord (6.0.3.5)
      activemodel (= 6.0.3.5)
      activesupport (= 6.0.3.5)
    activestorage (6.0.3.5)
      actionpack (= 6.0.3.5)
      activejob (= 6.0.3.5)
      activerecord (= 6.0.3.5)
      marcel (~> 0.3.1)
    activesupport (6.0.3.5)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
      zeitwerk (~> 2.2, >= 2.2.2)
    addressable (2.7.0)
      public_suffix (>= 2.0.2, < 5.0)
    bcrypt (3.1.16)
    bindex (0.8.1)
    bootsnap (1.7.2)
      msgpack (~> 1.0)
    builder (3.2.4)
    byebug (11.1.3)
    capybara (3.35.3)
      addressable
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.8)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (>= 1.5, < 3.0)
      xpath (~> 3.2)
    chartkick (3.4.2)
    childprocess (3.0.0)
    concurrent-ruby (1.1.8)
    crass (1.0.6)
    devise (4.7.3)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0)
      responders
      warden (~> 1.2.3)
    erubi (1.10.0)
    faraday (1.3.0)
      faraday-net_http (~> 1.0)
      multipart-post (>= 1.2, < 3)
      ruby2_keywords
    faraday-net_http (1.0.1)
    ffi (1.15.0)
    figaro (1.2.0)
      thor (>= 0.14.0, < 2)
    font-awesome-sass (5.15.1)
      sassc (>= 1.11)
    globalid (0.4.2)
      activesupport (>= 4.2.0)
    i18n (1.8.9)
      concurrent-ruby (~> 1.0)
    jbuilder (2.11.2)
      activesupport (>= 5.0.0)
    json (2.5.1)
    jwt (2.2.2)
    listen (3.4.1)
      rb-fsevent (~> 0.10, >= 0.10.3)
      rb-inotify (~> 0.9, >= 0.9.10)
    loofah (2.9.0)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    marcel (0.3.3)
      mimemagic (~> 0.3.2)
    method_source (1.0.0)
    mimemagic (0.3.5)
    mini_mime (1.0.2)
    mini_portile2 (2.5.0)
    minitest (5.14.4)
    msgpack (1.4.2)
    multi_json (1.15.0)
    multi_xml (0.6.0)
    multipart-post (2.1.1)
    mysql2 (0.5.3)
    nio4r (2.5.7)
    nokogiri (1.11.1)
      mini_portile2 (~> 2.5.0)
      racc (~> 1.4)
    oauth2 (1.4.4)
      faraday (>= 0.8, < 2.0)
      jwt (>= 1.0, < 3.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (>= 1.2, < 3)
    orm_adapter (0.5.0)
    pdf-core (0.9.0)
    prawn (2.4.0)
      pdf-core (~> 0.9.0)
      ttfunk (~> 1.7)
    public_suffix (4.0.6)
    puma (4.3.7)
      nio4r (~> 2.0)
    pundit (2.1.0)
      activesupport (>= 3.0.0)
    quickbooks-ruby (1.0.15)
      activemodel (> 4.0)
      multipart-post
      nokogiri
      oauth2 (~> 1.4)
      roxml (~> 4.0)
    racc (1.5.2)
    rack (2.2.3)
    rack-proxy (0.6.5)
      rack
    rack-test (1.1.0)
      rack (>= 1.0, < 3)
    rails (6.0.3.5)
      actioncable (= 6.0.3.5)
      actionmailbox (= 6.0.3.5)
      actionmailer (= 6.0.3.5)
      actionpack (= 6.0.3.5)
      actiontext (= 6.0.3.5)
      actionview (= 6.0.3.5)
      activejob (= 6.0.3.5)
      activemodel (= 6.0.3.5)
      activerecord (= 6.0.3.5)
      activestorage (= 6.0.3.5)
      activesupport (= 6.0.3.5)
      bundler (>= 1.3.0)
      railties (= 6.0.3.5)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.3.0)
      loofah (~> 2.3)
    railties (6.0.3.5)
      actionpack (= 6.0.3.5)
      activesupport (= 6.0.3.5)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.20.3, < 2.0)
    rake (13.0.3)
    rb-fsevent (0.10.4)
    rb-inotify (0.10.1)
      ffi (~> 1.0)
    regexp_parser (2.1.1)
    responders (3.0.1)
      actionpack (>= 5.0)
      railties (>= 5.0)
    roxml (4.1.1)
      activesupport (>= 4.0)
      nokogiri (>= 1.3.3)
    ruby2_keywords (0.0.4)
    rubyzip (2.3.0)
    sass-rails (6.0.0)
      sassc-rails (~> 2.1, >= 2.1.1)
    sassc (2.1.0)
      ffi (~> 1.9)
    sassc-rails (2.1.2)
      railties (>= 4.0.0)
      sassc (>= 2.0)
      sprockets (> 3.0)
      sprockets-rails
      tilt
    selenium-webdriver (3.142.7)
      childprocess (>= 0.5, < 4.0)
      rubyzip (>= 1.2.2)
    spring (2.1.1)
    spring-watcher-listen (2.0.1)
      listen (>= 2.7, < 4.0)
      spring (>= 1.2, < 3.0)
    sprockets (4.0.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.2)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    thor (1.1.0)
    thread_safe (0.3.6)
    tilt (2.0.10)
    ttfunk (1.7.0)
    turbolinks (5.2.1)
      turbolinks-source (~> 5.2)
    turbolinks-source (5.2.0)
    tzinfo (1.2.9)
      thread_safe (~> 0.1)
    warden (1.2.9)
      rack (>= 2.0.9)
    web-console (4.1.0)
      actionview (>= 6.0.0)
      activemodel (>= 6.0.0)
      bindex (>= 0.4.0)
      railties (>= 6.0.0)
    webdrivers (4.6.0)
      nokogiri (~> 1.6)
      rubyzip (>= 1.3.0)
      selenium-webdriver (>= 3.0, < 4.0)
    webpacker (4.3.0)
      activesupport (>= 4.2)
      rack-proxy (>= 0.6.1)
      railties (>= 4.2)
    websocket-driver (0.7.3)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.5)
    wicked_pdf (2.1.0)
      activesupport
    wkhtmltopdf-binary (0.12.6.5)
    xero-ruby (2.8.0)
      faraday (~> 1.0, >= 1.0.1)
      json (~> 2.1, >= 2.1.0)
    xpath (3.2.0)
      nokogiri (~> 1.8)
    zeitwerk (2.4.2)

PLATFORMS
  ruby

DEPENDENCIES
  bootsnap (>= 1.4.2)
  byebug
  capybara (>= 2.15)
  chartkick
  devise
  figaro
  font-awesome-sass
  jbuilder (~> 2.7)
  listen (~> 3.2)
  mysql2 (>= 0.4.4)
  prawn
  puma (~> 4.1)
  pundit
  quickbooks-ruby
  rails (~> 6.0.3, >= 6.0.3.2)
  sass-rails (>= 6)
  sassc (~> 2.1.0)
  selenium-webdriver
  spring
  spring-watcher-listen (~> 2.0.0)
  turbolinks (~> 5)
  tzinfo-data
  web-console (>= 3.3.0)
  webdrivers
  webpacker (~> 4.0)
  wicked_pdf
  wkhtmltopdf-binary
  xero-ruby

RUBY VERSION
   ruby 2.6.6p146

BUNDLED WITH
   2.2.13

我还创建了2个扩展文件

nginx_timeout.config:

  "/etc/nginx/conf.d/custom_nginx.conf":
    content: |
      keepalive_timeout           600;
      proxy_connect_timeout       600;
      proxy_send_timeout          600;
      proxy_read_timeout          600;
      send_timeout                600;

和Packages.config:

# These are things that make sense for any Ruby application

# Install git in order to be able to bundle gems from git
packages:
  yum:
    git: []
    patch: []

commands:
  #01 && 02 needs for build native extension. See https://forums.aws.amazon.com/thread.jspa?messageID=550901&#550053
  01_bundlerfix_command:
    test: test ! -f /opt/elasticbeanstalk/containerfiles/.post-provisioning-complete
    command: gem install rubygems-update -v '<3'
    leader_only: false
  02_update_rubygems:
    test: test ! -f /opt/elasticbeanstalk/containerfiles/.post-provisioning-complete
    command: $(which update_rubygems)
    leader_only: false
  # Run rake with bundle exec to be sure you get the right version
  add_bundle_exec:
    test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
    cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
    # 複数マッチ対応と上書き防止(後読み)
    command: perl -pi -e 's/((?<!bundle exec )rake)/bundle exec $1/g' 11_asset_compilation.sh 12_db_migration.sh
  # Bundle with --deployment as recommended by bundler docs
  #   cf. http://gembundler.com/v1.2/rationale.html under Deploying Your Application
  add_deployment_flag:
    test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
    cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
    # 複数マッチ対応と上書き防止(先読み)
    command: perl -pi -e 's/(bundle install(?! --deployment))/$1 --deployment/' 10_bundle_install.sh
  # Vendor gems to a persistent directory for speedy subsequent bundling
  make_vendor_bundle_dir:
    test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
    command: mkdir -p /var/app/support/vendor_bundle
  # Store the location of vendored gems in a handy env var
  set_vendor_bundle_var:
    test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
    cwd: /opt/elasticbeanstalk/support
    command: sed -i '12iexport EB_CONFIG_APP_VENDOR_BUNDLE=$EB_CONFIG_APP_SUPPORT/vendor_bundle' envvars
  # The --deployment flag tells bundler to install gems to vendor/bundle/, so
  # symlink that to the persistent directory
  symlink_vendor_bundle:
    test: test ! -f /opt/elasticbeanstalk/support/.post-provisioning-complete
    cwd: /opt/elasticbeanstalk/hooks/appdeploy/pre
    command: sed -i 's/(^cd $EB_CONFIG_APP_ONDECK)/1
ln -s $EB_CONFIG_APP_VENDOR_BUNDLE ./vendor/bundle/' 10_bundle_install.sh
  # Don't run the above commands again on this instance
  #   cf. http://stackoverflow.com/a/16846429/283398
  z_write_post_provisioning_complete_file:
    cwd: /opt/elasticbeanstalk/support
    command: touch .post-provisioning-complete

有什么想法可能导致此问题?

推荐答案

可能,除非有任何其他问题,否则将Gemfile中的机架锁定到1.6.8可以解决问题。

我自己在一个项目中使用了弹性豆茎,我经常后悔这个选择。每次平台更新时,我都需要将nio4r gem锁定到该平台所需的特定版本。还有美洲狮。太麻烦了。

正如您看到的其他遇到此问题的人一样,我们并不孤单;) 例如https://forums.aws.amazon.com/thread.jspa?messageID=957426

到目前为止,我还没有找到更好的解决方案,但话又说回来,我没有投入大量的时间来尝试。如果您这样做了,请告诉我;)

这篇关于有没有办法修复弹性豆茎中的Gem::LoadError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆