LoginSignup
0
0

More than 3 years have passed since last update.

解決!Your Ruby version is x.x.x, but your Gemfile specified x.x.x

Posted at

Herokuにデプロイしようとすると...

ruby のバージョンが 2.6.3 になっているけど、2.6.6 を使用しろと言われた。
この時点で参考にしたサイトはこちら。

まずはrbenv でバージョンを変えてみて確認する。

ターミナル
% rbenv global 2.6.6
% rbenv versions
  system
  2.5.1
  2.6.3
* 2.6.6 (set by /Users/randytozuka/.rbenv/version)

フムフム 2.6.6 になったね。
じゃ、念の為…

% ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

ありゃ? 2.6.3 のまま?! とりあえずbundle install してみっか・・・

% bundle install      
Your Ruby version is 2.6.3, but your Gemfile specified 2.6.6

やっぱり指導される…
プロジェクト直下に .ruby-version というものが生成されていてこれがある状態だと、rbenv で選択しているversion よりこちらが優先されるのでまずこのファイルを削除し、
その後 rbenv のバージョンを変え、
さらに Gemfiles の ruby '2.6.3' の記述も変更してから再度 bundle install!
…結果変わらず…

色々もがいた末に、

$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"

で、

% source ~/.bash_profile
% rbenv versions
  system
  2.5.1
  2.6.3
* 2.6.6 (set by /Users/randytozuka/.rbenv/version)

% ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin20]

お! なんとかうまく行った!!
2日彷徨いました・・・

0
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
0
0