首页 > 解决方案 > 如何解决“您的 Ruby 版本是 2.5.3,但您的 Gemfile 指定 2.5.1”部署 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 -vruby 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]

更多信息:

当我运行服务器时:

=> 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-on-railsrubyamazon-web-servicesamazon-ec2

解决方案


推荐阅读