[英]How to fix "Your Ruby version is 2.5.3, but your Gemfile specified 2.5.1" deploying the AWS eb?
问题:我在将应用程序部署到 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 版本)
我已经做好了:
ruby '2.5.3'
bundle update
bundle install
gem install bundler
gem update bundler
bundle update
d./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
捆绑环境显示:
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.3rbenv 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-version 设置)
bundler -v
:捆绑器版本 1.17.2
bundle platform --ruby
: ruby 2.5.3p105 which ruby
:/home/bob/.rbenv/shims/ruby
rails c
:
在进程 5437 中通过 Spring 预加载器运行加载开发环境 (Rails 5.2.2) irb(main):001:0>
which gem
:/home/bob/.rbenv/shims/gem
rbenv which gem
:/home/bob/.rbenv/versions/2.5.3/bin/gem which -a gem
:/home/bob/.rbenv/shims/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/.rbenv/shims:/home/bob/.rbenv/bin:/home/bob/.local/bin: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binruby-build --version
: ruby-build 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.
由于此错误与原始问题不同,因此我在这里创建了一个新问题: Deploying with AWWS EB but with 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 cli
与eb deploy
进行部署,但解决问题的方法是通过直接在 AWS Elastic Beanstalk 控制台中的Elastic Beanstalk > Applications > your-app > Application versions上传一个 zip 文件进行部署。
根据AWS 手册,该 zip 文件是使用git archive -v -o myapp.zip --format=zip HEAD
生成的。
我在这里回复是因为这是 Google 上的第一个 SO 链接,但这是对我有帮助的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.