What to do if you installed Ruby with rbenv but the version does not change

environment

MacOS Catalina Rails 6.0.3.2 Ruby 2.7.1(2.6.3)

phenomenon

There was no problem until the day before, but when I started the PC the next day and "Rails s", The error "Your Ruby version is 2.6.3, but your Gemfile specified 2.7.1" occurred.

If you check the version of Ruby Ruby -v → 2.6.3 rbenv --version → 2.7.1

I set it to "rbenv global 2.7.1", but it doesn't switch ...

approach

Confirmation of Ruby reference

$ which ruby
/usr/local/bin

Since it refers to a location different from the location installed by rbenv, change the location.

Change reference destination

$ vi ~/.bash_profile

The state of the file is as follows.

export PATH=/usr/local/bin:$PATH
export PATH="~/.rbenv/shims:/usr/local/bin:$PATH"
eval "$(rbenv init -)"
eval "$(rbenv init -)"
eval "$(rbenv init -)"

There is the same description that the first line seems to work, so modify it as follows.

export PATH="~/.rbenv/shims:/usr/local/bin:$PATH"
eval "$(rbenv init -)"

Use "dd" to delete one line of the used vi command, and ": wq" to save and exit.

Double check Ruby version

$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]

The Ruby version has switched successfully!

Recommended Posts

What to do if you installed Ruby with rbenv but the version does not change
What to do if the app is not created with the latest Rails version installed when rails new
What to do if the JSONHint annotation does not work with lombok and JSONIC
What to do if you change the Listen Address from the settings screen with Mattermost docker
[Ruby] How to use rbenv (version `x.x.x'is not installed)
[Swift] What to do if the app icon is set but not reflected
What to do if you should have installed Rails but an error occurs with rails -v (for beginners)
What to do if you get To install the missing version, run `gem install bundler: 2.1.4`
What to do if the update does not take effect after deploying Rails AWS
What to do if the breakpoint is shaded and does not stop during debugging
What to do if you cannot execute with the command "Java package name / class name"
What to do if FacesMessage is set but not displayed
What to do if you can't use the rails command
[Rails] What to do if you can't get an error message with the errors method
[Ubuntu 20.04] What to do if the external monitor is not recognized
What to do if validation doesn't work with the update action
What to do if you get angry with OpenSSL with pyenv install
What to do if you forget the root password in CentOS7
What to do if you cannot roll back the migration (UnknownMigrationVersionError)
[Rails] What to do if you can't get parameters with form_with
What to do if you select a JRE in Eclipse and get "The selected JRE does not support the current compliance level 11"
What to do if you install Ubuntu
What to do if the background image is not applied after deployment
What to do if you can't install the plugin from the Eclipse marketplace
What to do if deployment fails on Heroku (Ruby app not detected)
What to do if you don't like the code generated by swagger-codegen-cli
What to do if you can't bundle update and bundle install after installing Ruby 3.0.0 in the Rails tutorial
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if you get the error Too long with no output (exceeded 10m0s) on CircleCI
What to do if the server tomcat dies
Manage the version of Ruby itself with rbenv
What to do if you push incorrect information
What to do if you get Could not locate Gemfile or .bundle / directory
What to do if you can't activate the select box created by bootstrap-select
What to do if the changes are not reflected in the jar manifest file
[Grails] Error occurred running What to do when the Grails CLI does not start
repository The specified gem is bundle installed but not updated to the latest version
What to do if you have installed Java for OS X on macOS
What to do when is invalid because it does not start with a'-'
What to do if you have enabled Use the WSL2 based engine in Docker Desktop with insufficient WSL2 installation
What to do if the debug gem installation fails
What to do if the Rails server can't start
Correspondence when Ruby version does not switch in rbenv
What to do if you can't get the text of an element in Selenium
What to do if you get the error Couldn't find Item without an ID
What to do if you hit the wall of Too many symbol files when uploading with App Store Connect
Ruby version switching with rbenv
What to do if you get a java.io.IOException in GlassFish
[Java] [Spring] What to do if you cannot Autowire with Type Mismatch after annotating Spring Security
What to do when you launch an application with rails
If hash [: a] [: b] [: c] = 0 in Ruby, I want you to extend it recursively even if the key does not exist.
What to do if you don't see the test code error message in the terminal console
Ruby version does not switch
What to do if audio is not available on discordrb
What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
# What to do if you accidentally do rails db: migrate: drop
How to make a jar with old Hadoop (hadoop-core-0.20.2-cdh3u6) in Gradle: (What to do if you get Could not expand ZIP ..)
[Maven] What to do if you are asked to incorporate a jar that is not in the remote repository into the war
[Swift5] What to do if you want to commit files to github but there are too many
Memo that transitions to the login screen if you are not logged in with devise
What to do if the adb command cannot be executed