Your Ruby version is 2.4.6, but your Gemfile specified 2.6.4

When I tried to create a migration file, I was told that the Ruby version was different from the one specified in the Gemfile, and I could not execute it.

$ bin/rails g migration hoge
Your Ruby version is 2.4.6, but your Gemfile specified 2.6.4

Make sure rbenv is installed.

$ which rbenv
/usr/local/bin/rbenv

Install the specified Ruby version.

$ rbenv install 2.6.4
Downloading openssl-1.1.1g.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
Installing openssl-1.1.1g...
Installed openssl-1.1.1g to /Users/tamu/.rbenv/versions/2.6.4

Downloading ruby-2.6.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.4.tar.bz2
Installing ruby-2.6.4...
ruby-build: using readline from homebrew
Installed ruby-2.6.4 to /Users/tamu/.rbenv/versions/2.6.4

Confirm that it has been installed.

$ rbenv versions
  system
* 2.4.6 (set by /Users/tamu/.rbenv/version)
  2.6.4

This time, I wanted to apply it only under a specific directory, so specify as follows.

$ rbenv local 2.6.4

Confirm that it has switched.

$ ruby -v
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-darwin18]

Recommended Posts

Your Ruby version is 2.4.6, but your Gemfile specified 2.6.4
[Ruby version error] How to solve Your Ruby version is ~, but your Gemfile specified ~
Behavior when wild card (**) is specified in ruby
The ruby version is managed in the .rbenv / version file
repository The specified gem is bundle installed but not updated to the latest version
I specified the version and rails new, but for some reason the latest version is included ~
[Ruby] What is true?