如何修复部署 AWS eb "Your Ruby version is 2.5.3, but your Gemfile specified 2.5.1"?



问题:我在将应用程序部署到AWS EB时遇到问题,我在SO和谷歌上找到的每一种补救措施都无助于我的处境。

我安装了AWS EB命令行,并希望在那里部署我构建的应用程序,但在尝试解决后,我一直收到这个错误:

ERROR   [Instance: i-065ec77b2c530362b] Command failed on instance. Return code: 18 Output: (TRUNCATED)...g: the running version of Bundler (1.16.2) is older than the version that created the lockfile (1.17.2). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Your Ruby version is 2.5.3, but your Gemfile specified 2.5.1. 
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.
2018-12-21 08:51:28    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].

这个应用程序最初是用2.5.1构建的,但我今天把它切换到2.5.3,这样我就可以把它放在AWS上了。(我有这两个带有rbenv的ruby版本)

我已经完成了:

  • 在Gemfile中设置ruby '2.5.3'
  • bundle update
  • bundle install
  • gem install bundler
  • gem update bundler
  • 删除的gem锁文件和bundle updated
  • ./bin/spring stop(弹簧未运行)

ruby -v就是ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux](这只是本地的,我将rbenv全局设置为2.5.1,但我不认为这是一个问题,因为错误表明我是gemfile)

我在更新或安装捆绑后完成了rbenv rehash

bundle update --ruby

Gemfile.lock显示2.5.3

bundle env显示:

RUBY VERSION
ruby 2.5.3p105
BUNDLED WITH
1.17.2
```

我的整个Gemfile-以防万一这可能会有所帮助:

gem 'dotenv-rails', groups: [:development, :test]
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.3'
gem 'rails', '~> 5.2.1'
gem 'stripe'
gem 'stripe_event'
gem 'pry'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
gem 'pg'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem "chartkick"
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
# gem 'redis', '~> 4.0'
gem 'api-pagination', '~> 4.1', '>= 4.1.1'
gem 'will_paginate', '~> 3.1', '>= 3.1.6'
gem 'groupdate'
gem 'blazer'    
gem 'ahoy_matey'    
gem 'devise'
gem 'cancancan', '~> 2.0'
gem 'carrierwave', '~> 1.0'
gem 'carrierwave-aws'
gem 'carrierwave-ffmpeg'
gem 'carrierwave-video'
gem 'bootstrap', '~> 4.1.3'
gem 'sprockets-rails', :require => 'sprockets/railtie'
gem 'sprockets'
gem 'jquery-rails'
gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

更多信息:

  • rbenv local:2.5.3
  • rbenv global:2.5.1
  • bundle exec which ruby:/home/bob/.rbenv/versions/2.5.3/bin/ruby-

  • rbenv versions:系统2.5.1

    2.5.3(由/home/bob/Apps/uploader-master-side-3/.ruby版本设置)

  • bundler -v:Bundler版本1.17.2

  • bundle platform --ruby:红宝石2.5.3p105
  • which ruby:/home/bob/.rbenv/垫片/ruby

  • rails c:

    在进程5437中通过Spring预加载程序运行加载开发环境(Rails 5.2.2)irb(主):001:0>

  • which gem:/home/bob/.rbenv/垫片/gem

  • rbenv which gem:/home/bob/.rbenv/versions/2.5.3/bin/gem
  • which -a gem:/home/bob/.rbenv/垫片/gem/usr/bin/gem

  • rbenv which bundle:/home/bob/.rbenv/versions/2.5.3/bin/bundle

  • echo $PATH:/home/bob/.rbenv/plugins/ruby build/bin:/home/bob/.rebenv/shinms:/home/bbob/.local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/usr/games:/usr/local/games:/snap/bin
  • ruby-build --version:ruby构建20181106-14-g1ec9abd

当我运行服务器时:

=> Booting Puma
=> Rails 5.2.2 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.0 (ruby 2.5.3-p105), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop

感谢您抽出时间阅读本文并提供帮助!!!

棺材上的钉子:

我刚刚拿到了我在更新到新ruby之前创建的应用程序的副本,并尝试部署它,得到了这个:

Your Ruby version is 2.5.3, but your Gemfile specified 2.5.1. 
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.
2018-12-21 11:04:39    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].

这是2.5.1在全局和本地设置的

我还有什么其他选择?删除并重新安装rbenv?制作一个新的应用程序并复制除gemfile之外的所有内容?我没有选择和想法了,看起来像

更新:

我不知道AWS EB是基于我的git提交的,在尝试之前我从未更新过它们。。。(哇)现在我没有收到ruby版本错误。。。

所以现在我没有得到版本错误,但我得到了这个错误:

2018-12-21 22:50:56    ERROR   [Instance: i-00ae954ad2b716b2a] Command failed on instance. Return code: 1 Output: (TRUNCATED)...lizers/carrierwave.rb:1:in `<main>'
/var/app/ondeck/config/environment.rb:5:in `<main>'
/opt/rubies/ruby-2.5.3/bin/bundle:23:in `load'
/opt/rubies/ruby-2.5.3/bin/bundle:23:in `<main>'
Tasks: TOP => environment
(See full trace by running task with --trace). 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2018-12-21 22:50:56    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2018-12-21 22:51:58    ERROR   Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

由于这个错误与最初的问题不同,我在这里创建了一个新的错误:使用AWWS EB部署,但使用erors 部署

我在将平台从Ruby 3.0 Amazon Linux 2/3.4.4升级到Ruby 3.0 Amazon Linux 2/3.4.6后遇到了这个问题,这将升级Ruby 3.0.3->3.0.4

我使用eb clieb deploy进行部署,但解决问题的是通过直接在AWS Elastic Beanstalk控制台中上传zip文件进行部署,位于Elastic Beanstalk>应用程序>您的应用程序>应用程序版本

根据AWS手册,zip文件是用git archive -v -o myapp.zip --format=zip HEAD生成的。

我在这里回复是因为这是谷歌上的第一个SO链接,但这是帮助我的答案

相关内容

最新更新