[RAILS] I changed the Ruby version and now I can't bundle install

Incident occurred

It was one day

$ bundle install

When you enter

Traceback (most recent call last):
~/.rbenv/versions/2.5.0/bin/ruby: invalid option -:  (-h will show valid options) (RuntimeError)

Yeah yeah what is this! It doesn't accept other commands, what did you do ...

Let's look back on the past

I must have done something deadly ...

Ruby: Developed with 2.7

(My environment)/vendor/bundle/ruby/2.7.0/gems/active_hash-3.1.0/lib/associations/associations.rb:22: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
(My environment)/vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.3.1/lib/active_record/associations.rb:1657: warning: The called method `belongs_to' is defined here

I get a lot of warnings when I enter Rails commands and it's annoying The gem warning is important, but ok

Deal with adding environment variables

export RUBYOPT='-W:no-deprecated -W:no-experimental'

The warning disappeared when I added the above to .zshrc It's stress-free

I had to lower the version of Ruby and develop it

Since development with another version became indispensable, I lowered the version (Ruby: 2.5)

Traceback (most recent call last):
~/.rbenv/versions/2.5.0/bin/ruby: invalid option -:  (-h will show valid options) (RuntimeError)

Until now, this didn't happen with another version ...

Conclusion

export RUBYOPT='-W:no-deprecated -W:no-experimental'

I solved it by removing this from the environment variables. Don't forget to remove it when the gem version goes up and you don't get any warnings.

reference

https://qiita.com/mojihige/items/ce3282bec0c58f8ba637 https://qiita.com/hirocueki2/items/010c777d2125ee120a8e

Recommended Posts

I changed the Ruby version and now I can't bundle install
What to do if you can't bundle update and bundle install after installing Ruby 3.0.0 in the Rails tutorial
[Ruby] I thought about the difference between each_with_index and each.with_index
[Ruby] I can't install puma on Mac [Rails, etc.]
When I changed to M1 mac, bundle install became impossible
[Rails] What is the difference between bundle install and bundle update?
What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
Difference between bundle and bundle install
Webpack and webpacker I want to tell Ruby people right now
I made a Ruby container image and moved the Lambda function
I want to add devise in Rails, but I can't bundle install
I passed Ruby Gold, so I summarized the study methods (November 2020 version)
I don't see an error in Rails bundle install ... the solution
I can't install lombok with Gradle.
Project ruby and rails version upgrade
Why I have 10 years of experience in Ruby and don't run the [absolutely] gem install rails command
I get an error with bundle install and puma cannot be installed.
[Ruby] I want to extract only the value of the hash and only the key
Copying the repository and getting a mysql2 error on the first bundle install
[Memo] Difference between bundle install and update
I can't install rails on my mac
Download and install Eclipse (Java) (Mac version)
How to install the legacy version [Java]
I studied the State pattern and the Strategy pattern
[heroku deployment procedure ③] From Ruby version specification to deployment and access to the application (complete)