Your Ruby version is 2.6.6, but your Gemfile specified >= 2.7.0, < 3.1

6,107 views
Skip to first unread message

Hyim Brandes

unread,
May 2, 2022, 9:54:11 AM5/2/22
to Canvas LMS Users
Hi Everyone,

I am trying to upgrade an existing canvas install (from mid 2021) on Ubuntu 20.04.4 LTS (that had been using rails 2.6.6) to the latest production version.  
I installed Ruby 2.7 and when I run:
         $ ruby -v
I get:
         ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux-gnu]

but when I run:
         $GEM_HOME/bin/bundle install
I get the error:
         Your Ruby version is 2.6.6, but your Gemfile specified >= 2.7.0, < 3.1
When I run:
         $ gem env
I get:

         RubyGems Environment:
           - RUBYGEMS VERSION: 3.3.12
           - RUBY VERSION: 2.6.6 (2020-03-31 patchlevel 146) [x86_64-linux-gnu]
           - INSTALLATION DIRECTORY: /var/lib/gems/2.6.0
           - USER INSTALLATION DIRECTORY: /home/USERDIR/.local/share/gem/ruby/2.6.0
           - RUBY EXECUTABLE: /usr/bin/ruby2.6
           - GIT EXECUTABLE: /usr/bin/git
           - EXECUTABLE DIRECTORY: /usr/local/bin
           - SPEC CACHE DIRECTORY: /home/USERDIR/.local/share/gem/specs
           - SYSTEM CONFIGURATION DIRECTORY: /etc
           - RUBYGEMS PLATFORMS:
              - ruby
              - x86_64-linux
           - GEM PATHS:
              - /var/lib/gems/2.6.0
              - /home/USERDIR/.local/share/gem/ruby/2.6.0
              - /usr/lib/ruby/gems/2.6.0
              - /usr/share/rubygems-integration/2.6.0
              - /usr/share/rubygems-integration/all
              - /usr/lib/x86_64-linux-gnu/rubygems-integration/2.6.0
           - GEM CONFIGURATION:
              - :update_sources => true
              - :verbose => true
              - :backtrace => false
              - :bulk_threshold => 1000
           - REMOTE SOURCES:
              - https://rubygems.org/
           - SHELL PATH:
              - /usr/local/sbin
              - /usr/local/bin
              - /usr/sbin
              - /usr/bin
              - /sbin
              - /bin
              - /usr/games
              - /usr/local/games
              - /snap/bin

How do I update the ENV to point to and use the correct version of rails? Any help would be GREATLY appreciated.

mcannon83

unread,
May 24, 2022, 9:36:02 AM5/24/22
to Canvas LMS Users
I ran into something similar, here's what worked for me on Ubuntu 16.04.7:

1. sudo apt-get install ruby2.7 ruby2.7-dev
2. sudo update-alternatives --config gem (switch to latest version)
3. sudo update-alternatives --config ruby (switch to latest version)
4. At this stage I rebooted because 'gem env' still reported the old version (rebooted ec2 instance from console).
5. After rebooting 'gem env' picked up the correct version of Ruby, but 'bundle install' still complained about the old version.
6. Finally I reinstalled bundler: sudo gem install bundler --version 2.2.19 (this fixed the issue for me).

After that 'bundle install' ran. 

Nico López

unread,
May 28, 2022, 12:44:26 AM5/28/22
to Canvas LMS Users
Maybe you can try ruby-switch:

sudo apt-get install ruby-switch

ruby-switch --list

sudo ruby-switch --set ruby2.7

ruby -v



Reply all
Reply to author
Forward
0 new messages