LoginSignup
5
0

More than 3 years have passed since last update.

Rubyのバージョンを変えたらbundle installができなくなった

Last updated at Posted at 2020-05-24

事件発生

ある日のことだった

$ bundle install

を入力すると

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

ええええ何だこれ!
他のコマンドも受け付けてくれない、何をしでかしたんだ…

これまでを振り返ってみよう

自分が致命的な何かをしてしまったはず…

Ruby : 2.7 で開発していた

(自分の環境)/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
(自分の環境)/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

Railsコマンドを入力すると警告がたくさん出て鬱陶しいな
gemの警告は大事だけどまあいっか

環境変数を追加して対処

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

.zshrcに上を追加したら警告が消えたよストレスフリーだね

Rubyのバージョンを下げて開発しなければならなくなった

別バージョンでの開発が不可欠になったのでバージョンを下げました(Ruby:2.5)

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

今までは別のバージョンにしてもこんなこと起きなかったのにな…

結論

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

環境変数からこれを削除したら解決しました。
gemのバージョンが上がって警告が出なくなったら忘れずに削除しないとね。

参考

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

5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0