LoginSignup
1
0

More than 1 year has passed since last update.

バージョン指定で"rails new"したら"Gem::GemNotFoundException"でコケたとき用

Last updated at Posted at 2022-03-17

そもそも

  • 現場Railsの3章、"taskleaf"アプリケーションの準備段階で躓く(バージョン指定でnewが出来ず)
  • バージョン指定での"rails new"以外の方法があるっぽいので実践してみたログ

手順

アプリのディレクトリを作成する

mkdir hoge

ディレクトリに移動

cd hoge

bundle initする

  • (これ要るのか?要調査)
bundle init

できたGemfileにRailsのバージョンを書き込む

Gemfile
gem "rails", '5.2.1'

bundle installする

bundle install

Rails new(質問にはYで答える)

$ rails _5.2.1_ new . -d postgresql --skip-bundle

Gemfileのsass-railsのバージョン指定を外す

  • 次にbundle installする時にエラーが出るため
Gemfile
gem 'sass-rails'

bundle installしようとするも、"pg"がインストールできずにコケたので対策

  • エラーメッセージを辿ると、"pg_config"が見つからなかったようでした
  • 解決するのに2時間はかかった
pg_configを探す
find / -name pg_config
postgresqlをビルドする時に参照するパスを変更
bundle config build.pg --with-pg-config=/opt/homebrew/Cellar/postgresql/14.2_1/bin/pg_config

bundle install

  • 通ったときの喜びはひとしお
bundle install

omake

PostgreSQL起動停止確認コマンド
brew services start postgresql
brew services stop postgresql
brew services list

疲れた

Rails Tutorial完走→現場Railsに入ったばかりのナメクジ並感

  • もしかして、環境構築って鬼門なのでは?
  • 2度と同じ轍を踏まないようにしよう
  • こうやってやったことログを残すのが楽しいことに気づいた
  • これからもよろしくお願いします

参照

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