LoginSignup
0
1

More than 1 year has passed since last update.

railsで指定したバージョンがインストールできない場合

Posted at

概要

railsの学び直しをしようと、新しい環境を作った際に、指定したバージョンをインストールしたはずなのにできていなかった時のまとめです。

環境

AWS
cloud9
mac
Linux

起こっていたこと

ターミナル
ec2-user:~/environment/アプリ名 (main) $ gem install rails -v 7.0.4
Successfully installed rails-7.0.4
1 gem installed
ec2-user:~/environment/アプリ名 (main) $ rails -v
Rails 6.1.7.2

あれ?rails7.0.4を指定したし、installできたってあるのにversionが違う...

解決法

Gemfile.lockを見ましょう。

Gemfile.lock
    rails (6.1.7.2)
      actioncable (= 6.1.7.2)
      actionmailbox (= 6.1.7.2)
      actionmailer (= 6.1.7.2)
      actionpack (= 6.1.7.2)
      actiontext (= 6.1.7.2)
      actionview (= 6.1.7.2)
      activejob (= 6.1.7.2)
      activemodel (= 6.1.7.2)
      activerecord (= 6.1.7.2)
      activestorage (= 6.1.7.2)
      activesupport (= 6.1.7.2)
      bundler (>= 1.15.0)
      railties (= 6.1.7.2)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.5.0)
      loofah (~> 2.19, >= 2.19.1)
    railties (6.1.7.2)
      actionpack (= 6.1.7.2)
      activesupport (= 6.1.7.2)

よく見れば、rails周りの設定のバージョンが6.1.7.2になっていたので下記のように直しました。

Gemfile.lock
    rails (7.0.4)
      actioncable (= 7.0.4)
      actionmailbox (= 7.0.4)
      actionmailer (= 7.0.4)
      actionpack (= 7.0.4)
      actiontext (= 7.0.4)
      actionview (= 7.0.4)
      activejob (= 7.0.4)
      activemodel (= 7.0.4)
      activerecord (= 7.0.4)
      activestorage (= 7.0.4)
      activesupport (= 7.0.4)
      bundler (>= 1.15.0)
      railties (= 7.0.4)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.5.0)
      loofah (~> 2.19, >= 2.19.1)
    railties (7.0.4)
      actionpack (= 7.0.4)
      activesupport (= 7.0.4)

結果

ターミナル
ec2-user:~/environment/アプリ名 (main) $ gem install rails -v 7.0.4
Successfully installed rails-7.0.4
1 gem installed
ec2-user:~/environment/アプリ名 (main) $ rails -v
Rails 7.0.4

治りました!

思ったこと

今回はどの記事も見ることなく解決ができました。
知識だけではダメですが、プログラミングを上達させる手段は、いっぱいプログラムに触れて、いろいろなことを知ることが一番の近道ではないしょうか。
そんなことを思いました。
私も初心者なので、まだまだいっぱい勉強をしていこうと思います。

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