0
ruby -v

ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

cat Gemfile.lock | grep -A 2 RUBY

RUBY VERSION

   ruby 2.7.1p83

bundle platform --ruby

ruby 2.7.1p83

sudo rake db:create

Your Ruby version is 2.7.0, but your Gemfile specified 2.7.1

I can't see what is the problem here. This is a fresh installation of Ubuntu it's 20.04 and I was trying to set up a ruby on rails env for the first time.

dejanualex
  • 3,872
  • 6
  • 22
  • 37
  • 2
    You shouldn't need `sudo` to run rake tasks. Try a simple `bundle exec rake db:create` – eugen Oct 16 '20 at 12:47
  • Have you tried the solution for another ruby versions? https://stackoverflow.com/questions/23039528/your-ruby-version-is-2-0-0-but-your-gemfile-specified-2-1-0 – Yurii Verbytskyi Oct 16 '20 at 14:09

1 Answers1

2

Different users can have different versions of ruby installed.

When you run ruby -v you will see the version of ruby in your user environment.

When you run sudo rake ... (or sudo anything) you will use the version of ruby in the super user’s environment.

In short, don’t use sudo. bundle exec rake db:migrate Will ensure you’re using the same version of ruby as you see in the output of bundle platform —ruby

To help understand what’s happening when you try to check the version, try sudo ruby -v That should be where v2.7.0 comes from

Tom Harvey
  • 3,681
  • 3
  • 19
  • 28