0
0

More than 3 years have passed since last update.

【Rails】Rails起動時のエラー対処法:Your Ruby version is 3.0.0, but your Gemfile specified 2.7.0

Posted at

rails sでサーバーを起動するとRubyのGemfileのバージョンと指定しているRubyのバージョンが異なるというエラーが表示されたので、
この対処法。

症状

$ rails -s
Your Ruby version is 3.0.0, but your Gemfile specified 2.7.0

▼rubyとrbenvのバージョン
どちらも同じバージョンを指している。

$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]

$ rbenv version
3.0.0 (set by /Users/***/projects/my-pj/demo-rails/.ruby-version)


対処法

GemfileのRubyのバージョンを変更(シンプル。)

Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.0' #修正
修正を反映
$ bundle install
起動
$ rails s
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Use Ctrl-C to stop

image.png

指定したrubyのバージョンで起動完了。

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