The ruby version is managed in the .rbenv / version file

.rbenv/version

The .rbenv / version file describes the ruby version you are currently using. If you change the version with the rbenv global x.x.x command etc., the contents of .rbenv / version will also be rewritten.

[ec2-user@al1-gemlist ~]$ ruby -v
ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux]
[ec2-user@al1-gemlist ~]$ cat .rbenv/version
2.5.7
[ec2-user@al1-gemlist ~]$ rbenv global 2.5.8
[ec2-user@al1-gemlist ~]$ ruby -v
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
[ec2-user@al1-gemlist ~]$ cat .rbenv/version
2.5.8

What happens when I edit .rbenv / version

Then, what happens if you edit .rbenv / version with vi? As a test, change the contents of .rbenv / version from 2.5.8 to 2.5.0.

[ec2-user@al1-gemlist ~]$ sudo vi .rbenv/version
[ec2-user@al1-gemlist ~]$ cat .rbenv/version
2.5.0
[ec2-user@al1-gemlist ~]$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]

You can see that the version of ruby has been changed according to the contents of the file. Also, if you check with the rbenv versions command,

[ec2-user@al1-gemlist ~]$ rbenv versions
  system
* 2.5.0 (set by /home/ec2-user/.rbenv/version)
  2.5.1
  2.5.2
  2.5.3
  2.5.4
  2.5.5
  2.5.6
  2.5.7
  2.5.8
  2.6.2

It can be confirmed that this is also 2.5.0.

Question

However, there is one question here. I understand that the version of ruby is displayed as 2.5.0 on the version confirmation command, but it means "Is it changed to 2.5.0 internally?"

As a confirmation method, check the version of the gem called openssl. This gem is When ruby is 2.5.8 2.1.2 If ruby is 2.5.0, it will be 2.1.0. (For details, refer to here)

In other words, if the version of openssl is 2.1.0, it can be said that the ruby version has been changed to 2.5.0 internally.

result

[ec2-user@al1-gemlist ~]$ gem list openssl

*** LOCAL GEMS ***

openssl (default: 2.1.0)

Therefore, it was confirmed that it could be changed internally.

Recommended Posts

The ruby version is managed in the .rbenv / version file
Manage the version of Ruby itself with rbenv
Correspondence when Ruby version does not switch in rbenv
The migration file is duplicated
Ruby version switching with rbenv
Determine that the value is a multiple of 〇 in Ruby
What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
Unzip the zip file in Java
Is there no type in Ruby?
Try file locking in Ruby directory
openssl version information in ruby OPENSSL_VERSION
Spring Autowired is written in the constructor
[Technical memo] What is "include" in Ruby?
[Ruby] Your Ruby version is 2.6.3, but your Gemfile specified 2.5.8
Implement the algorithm in Ruby: Day 1 -Euclidean algorithm-
Memo: [Java] If a file is in the monitored directory, process it.
"" Application.js "is not present in the asset pipeline" error in Ruby on Rails
What is the best file reading (Java)
Your Ruby version is 2.4.6, but your Gemfile specified 2.6.4
What is the main method in Java?
[Ruby] How to prevent errors when nil is included in the operation
What is Pullback doing in The Composable Architecture
Behavior when wild card (**) is specified in ruby
The intersection type introduced in Java 10 is amazing (?)
Implement the algorithm in Ruby: Day 3 -Binary search-
[Java] Read the file in src / main / resources
Implement the algorithm in Ruby: Day 4-Linear search-
Get your version number in the Android app
How to build the simplest blockchain in Ruby
[Java] Something is displayed as "-0.0" in the output
When the project is not displayed in eclipse
Ebean.update () is not executed in the inherited model.
Implement the algorithm in Ruby: Day 2 -Bubble sort-
I want to get the value in Ruby
Class in Ruby
Heavy in Ruby! ??
Count the number of occurrences of a string in Ruby
In Time.strptime,% j (total date of the year) is
[Ruby on Rails Tutorial] Error in the test in Chapter 3
Access the war file in the root directory of Tomcat
Examine the elements in the array using the [Ruby] includes? Method
About the difference between classes and instances in Ruby
Which is better, Kotlin or Java in the future?
[Ruby] How to use rbenv (version `x.x.x'is not installed)
Calculate the difference between numbers in a Ruby array
[Ruby / Rails] Set a unique (unique) value in the class
[Java] Get the file in the jar regardless of the environment
[Java] Get the file path in the folder with List
How to debug the generated jar file in Eclipse
[Error] The app is not displayed in the production environment
Get the URL of the HTTP redirect destination in Ruby
Java11: Run Java code in a single file as is
Why the get method is needed in the Calendar class
The story that .java is also built in Unity 2018
I want to find out which version of java the jar file I have is available
What to do if you installed Ruby with rbenv but the version does not change
The version of Ruby that was installed by default on the Mac was referenced, not from rbenv
[Ruby] Thinking when there is no receiver in front of the method (it looks like)