1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

rbenvでrails newをできなかった話。

Posted at

1. 目次

2. 発生事項
3. 解決までの行動
4. 考察
5. 結論

2. 発生事項

rbenvを使用してrubyバージョンを管理していた時のこと。
事前に以下のバージョンのrubyおよびrailsをインストール済み状態であった。

  • ruby: 3.1.1
  • rails: 8.0.2

ここで、railsチュートリアルをしようと思い、
以下のrubyおよびrailsをインストールした。

  • ruby: 3.2.8
  • rails: 7.0.4.3

インストールまでは順調に実行できた。
rbenv local 3.2.8をprojectのディレクトリで実行した。
しかし、rails _7.0.4.3_ new sample_appを実行したときに
以下のような問題が発生した。

initialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)

    Logger::Severity.constants.each do |severity|

chatGPTによると以下の意味を示している
initialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)は、Logger というクラス(またはモジュール)が見つからない=未定義の定数として扱われていることを意味する。
Logger::Severity.constants.each do |severity|は、標準ライブラリの Logger クラスの中の Severity(ログのレベル:INFO, WARN など)から定数一覧を取得して処理しようとしている行である。

ちなみに、

  • rails: 7.2.2, 8.0.2

ではrails newを成功できている。

3. 解決までの行動

手動でのrails依存関係の作成

bundle init
echo "gem 'rails', '7.0.4.3'" >> Gemfile
bundle install

bundle exec rails new . --force --skip-bundle

bundle install

上記のコマンドを実行すると手動でrails newの代わりをできるらしい。
しかし、この方法では今回の問題は解決できなかった。

他のrubyバージョンで実行

ruby: 3.1.4
でrails rails _7.0.4.3_ new sample_appを実行した。
しかし、状況はからわず。

rubyの再インストール

rubyのビルド時に問題が発生していると考え、
rubyの再インストールを試した。
しかし、状況はからわず。

ruby-build時の外部ライブラリへの正しいリンク指定

~/.zshrcの内容を修正してみた。
目的はmac内部のrubyとの競合を解消するため。
しかし、状況は変わらず。

railsの複数バージョンインストールによる競合の解消

全てのrubyをアンインストールしてgemファイルが初期化されていることを確認した後、

  • 7.0.8.6
  • 7.2.2
  • 8.0.2

のそれぞれに対してrailsのインストールとrails newを行った。
しかし、状況は変わらず。

  • 7.2.2
  • 8.0.2

は成功した。

4. 考察

  • 7.0.8.6
  • 7.2.2
  • 8.0.2

のうち

  • 7.2.2
  • 8.0.2

は成功ことにより以下のように判断する。

  • rails 7.0.x系列では追加で必要な処理がある

5. 結論

以下のことがわかった。

バージョン 結果
7.0.4.3 不成功
7.0.8.6 不成功
7.2.2 成功
8.0.2 成功

今後も調査を進める。

1
0
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?