[RAILS] Correspondence when Ruby version does not switch in rbenv

Since the Ruby version did not switch in rbenv, it is a memo of it.

Event

It does not change even if you switch the version with rbenv

$ rbenv versions
  system
  2.6.6 
* 2.7.1 (set by RBENV_VERSION environment variable)
$ rbenv global 2.6.6
$ rbenv versions
  system
  2.6.6 
* 2.7.1 (set by RBENV_VERSION environment variable)

What i did

It says set by RBENV_VERSION environment variable, but I haven't written it anywhere. Also, if you do export RBENV_VERSION = 2.6.6 in .zshrc, the version of rbenv will change well, I get an error when I try to check the version of ruby.

$ rbenv versions
  system
* 2.6.6 (set by RBENV_VERSION environment variable) 
  2.7.1
$ ruby -v
/Users/naoto.koyama/.rbenv/versions/2.7.1/bin/ruby: invalid option -:  (-h will show valid options) (RuntimeError)

Cause

It was caused by writing the RUBYOPT setting written in .zshrc to suppress the Ruby 2.7 warning.

$ cat ~/.zshrc
...
export RUBYOPT='-W:no-deprecated -W:no-experimental' # <-This is the cause

If you delete the above and then type the following command, it's OK.

$ unset RUBYOPT
$ rbenv global 2.6.6
$ rbenv versions
  system
* 2.6.6 (set by /Users/naoto.koyama/workspace/portal/.ruby-version)
  2.7.1
$ ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin20]

reference

All ruby ​​commands in rbenv are "invalid option-: (-h will show valid options) (RuntimeError)", maybe due to RUBYOPT

Recommended Posts

Correspondence when Ruby version does not switch in rbenv
Ruby version does not switch
Final confirmation when ruby version does not switch
Do not return when memoizing in Ruby
The ruby version is managed in the .rbenv / version file
[Ruby] How to use rbenv (version `x.x.x'is not installed)
Ruby version switching with rbenv
[Ruby on Rails] When parameter id acquisition does not work
Docker does not work when DOCKER_HOST is specified in WSL2
What to do if you installed Ruby with rbenv but the version does not change
Handling when calling a key that does not exist in hash
Xcode does not support macOS in brew upgrade rbenv ruby-build error
Encoding when getting in Windows + Ruby
openssl version information in ruby OPENSSL_VERSION
[Error] Regarding rbenv: ruby 2.5.1 is not installed ot ~ when executing automatic deployment
Be careful when omitting return in Ruby
JavaScript (vanilla) does not respond in Rails.
MySQL container does not start in Docker
.sql file does not run in docker-compose
[NetBeans] Story when it does not start
What to do when rails db: seed does not reflect in the database
File manager does not start when logging in again in Docker's LXDE desktop environment
UriComponentsBuilder does not encode "+" depending on spring version
Escape processing when creating a URL in Ruby
Behavior when wild card (**) is specified in ruby
Manage the version of Ruby itself with rbenv
When @Transactional of Spring Boot does not work
@BeforeStep does not work in Tasklet of spring-batch
rbenv versions and ruby -v versions do not match
Does not recognize the library when implementing jcaptcha
When the project is not displayed in eclipse
Guidelines for writing processing when a value exists / does not exist in Java Optional
The presence or absence of! In Ruby method names does not mean destructive / non-destructive
"Do not show again" check does not work in the warning dialog when starting applet