How to fix "Your Ruby version is 2.5.3, but your Gemfile specified 2.5.1" deploying the AWS eb?

Viewed 3768

Issue: I am having issues deploying app to AWS EB and every remedy I have found on SO and google have not helped my situation.

I installed the AWS EB command line and looking to deploy an app I have built to there but i keep getting this error after attempts to resolve it:

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].

The app was initially built with 2.5.1 but I switched it to 2.5.3 today so I can put it onto AWS. (I have both of these ruby versions with rbenv)

I have done:

  • Set ruby '2.5.3' in Gemfile
  • bundle update
  • bundle install
  • gem install bundler
  • gem update bundler
  • deleted gem lock file and bundle updated
  • ./bin/spring stop (spring not running)

ruby -v is ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux] (this is local only, I have rbenv global set to 2.5.1, but I don't believe this is an issue as the error states i's the gemfile)

I have done rbenv rehash after updating or installing bundle

bundle update --ruby

Gemfile.lock shows 2.5.3

bundle env shows:

RUBY VERSION
   ruby 2.5.3p105

BUNDLED WITH
   1.17.2
```

My entire Gemfile - just in case this may help for something:

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]

More info:

  • 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: system 2.5.1

    2.5.3 (set by /home/bob/Apps/uploader-master-side-3/.ruby-version)

  • bundler -v: Bundler version 1.17.2

  • bundle platform --ruby: ruby 2.5.3p105
  • which ruby: /home/bob/.rbenv/shims/ruby

  • rails c:

    Running via Spring preloader in process 5437 Loading development environment (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/bin
  • ruby-build --version: ruby-build 20181106-14-g1ec9abd

When I run server:

=> 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

Thank you for your time and reading this and your help!!!

NAIL IN THE COFFIN:

I just took the copy of my app i created before updating to the new ruby and tried to deploy it and got this:

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].

.....this is which 2.5.1 set globally and locally

What other options do I have? Delete and re install rbenv? Make a new app and copy everything over except the gemfile? I'm out of options and ideas it seems like

UPDATE:

I had no clue that AWS EB was based off my git commits and i never updated them before trying... ( wow ) and now i don't receive the ruby version error...

So now i don't get the version error but I do get this error:

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.

Since this error is different from the original question, I have created a new one here: Deploying with AWWS EB but with erors

1 Answers

I was having this problem after upgrading the platform from Ruby 3.0 Amazon Linux 2/3.4.4 to Ruby 3.0 Amazon Linux 2/3.4.6, which upgrades Ruby 3.0.3 -> 3.0.4

I was using eb cli to deploy with, eb deploy, but what solve the issue was deploying via uploading a zip file directly in AWS Elastic Beanstalk console, in Elastic Beanstalk > Applications > your-app > Application versions.

The zip file was generated with git archive -v -o myapp.zip --format=zip HEAD, according to AWS manual.

I am replying here because this was the first SO link on Google, but this was the answer that helped me.

Related