How to deal with different versions of rbenv and Ruby

I'm just starting programming recently, but I'd like to mention the problems I had when trying to update Ruby to a new one and how to solve it.

The environment is MacBook Pro OS Catalina. The original version of Ruby was 2.6.3. When I tried to update to 2.7.2.

You should have installed 2.7.2 from the Ruby update command from rbenv

rbenv version

And when you look at the version,

2.7.2 (set by /Users/○○○(username)/.ruby-version) 

I get it,

ruby -v

When you put it in

ruby 2.6.3p62

The characters are ...

If you look at various sites

which ruby rbenv global 2.7.2

Even if you put it in, it doesn't change at all. Similarly, when I type in the article of the person who is in trouble, while the terminal is open, it is temporarily fixed, but when I close it and check the version again, it returns to 2.6.3.

This code was useful at that time.

echo 'eval "$(rbenv init -)"' >>  ~/.zshrc

from

source ~/.zshrc

from

rbenv global 2.7.2

I tried to put it. When I check it,

ruby 2.7.2p137

The character is!

Dreadfully close and reopen the terminal

ruby -v

When I put it in

ruby 2.7.2p137

The character came out! If you are having trouble with the same phenomenon, please give it a try.

reference: Progate: "Prepare a Ruby development environment!"

I solved it by referring to this code of Progate.

Recommended Posts

How to deal with different versions of rbenv and Ruby
Common problems with WSL and how to deal with them
How to install ruby through rbenv
[Ruby] 5 errors that tend to occur when scraping with Selenium and how to deal with them
Install Ruby 3.0.0 Preview 1 with a combination of Homebrew and rbenv
[Android] How to deal with dark themes
How to deal with Precompiling assets failed.
Convert JSON to TSV and TSV to JSON with Ruby
How to set different source / target versions for production code and test code
How to build an environment for any version of Ruby using rbenv
Java8 / 9 Beginners: Stream API addiction points and how to deal with them
How to insert processing with any number of elements in iterative processing in Ruby
JDBC promises and examples of how to write
How to find the cause of the Ruby error
[Ruby] How to convert from lowercase to uppercase and from uppercase to lowercase
[Ruby] How to use gsub method and sub method
[Ruby] "Reference to object" and "Contents of variable"
How to build API with GraphQL and Rails
Moved to anyenv! (Manage rbenv and nodenv with anyenv)
rbenv versions and ruby -v versions do not match
Ruby How to convert between uppercase and lowercase
How to convert a value of a different type and assign it to another variable
How to use Eclipse on my PC with 32bit and 2GB of memory
How to use rbenv
Diet program with preprocessor (how to deal with i-appli size)
How to deal with fatal: remote origin already exists.
How to make LINE messaging function made with Ruby
How to deal with No template for interactive request
[Ruby] How to find the sum of each digit
[Ruby] How to use rbenv (version `x.x.x'is not installed)
[Docker environment] How to deal with ActiveSupport :: MessageEncryptor :: InvalidMessage
[Rails] How to deal with URL changes after render
Install rbenv with apt on ubuntu and put ruby
How to handle TSV files and CSV files in Ruby
How to use RealSense with ubuntu 20.04 and ROS Noetic
How to boot by environment with Spring Boot of Maven
How to install Gradle and Kotlin with SDKMAN (Mac)
[Ruby] How to get the tens place and the ones place
(Ruby on Rails6) How to create models and tables
Manage multiple versions of Ruby on Mac [macOS + rbenv]
How to write offline real time Implementation example by ruby and C99 of F04
How to request by passing an array to the query with HTTP Client of Ruby
[Docker] How to update using a container on Heroku and how to deal with Migrate Error
[ruby] How to assign a value to a hash by referring to the value and key of another hash
How to set the retry limit of sidekiq and notify dead queues with slack
[Rough explanation] How to separate the operation of the production environment and the development environment with Rails
Explanation of Ruby on rails for beginners ④ ~ Naming convention and how to use form_Tag ~
[Ruby On Rails] How to search and save the data of the parent table from the child table
Ruby version switching with rbenv
How to use trained model of tensorflow2.0 with Kotlin / Java
How to divide a two-dimensional array into four with ruby
How to use Ruby return
Comparison of how to write Callback function (Java, JavaScript, Ruby)
[Easy] How to automatically format Ruby erb file with vsCode
[Ruby] How to comment out
Learning Ruby with AtCoder 13 How to make a two-dimensional array
How to number (number) with html.erb
How to update with activerecord-import
How to move another class with a button action of another class.
Impressions and memories of openssl, curl, ruby, homebrew, rbenv installation
Rbenv command to use Ruby