LoginSignup
133
96

More than 3 years have passed since last update.

Railsを始めてsqlite3まわりのエラーで躓いている人たちへ

Last updated at Posted at 2019-02-14

2019/02/04から、ふつうにrails newをするとsqlite3まわりでエラーが起きるようになっています。
teratailを見ていたら、1日に数件これ関連の質問が上がってきて阿鼻叫喚な感じだったので、こちらにまとめておきます。

(2019/03/28 追記)
Rails5.2.3がリリースされました!
この問題は解消されています。めでたしめでたし。

エラーメッセージ

Puma caught this error: Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile. (LoadError)

対処法

Gemfileを開いて、

gem 'sqlite3'

の行を

gem 'sqlite3', '~> 1.3.6'

に変更し、

$ bundle install

を実行します。

それでもエラーが出る場合

こんなエラーが報告されています。

ActiveRecord::ConnectionNotEstablished No connection pool with 'primary' found.

もしくは

「プライマリ」の接続プールが見つかりません。

おそらく、gemの更新が反映されていません。
rails serverを再起動してください。

原因

Rails側のsqlite3のバージョン指定の問題です。
1.3.6以上、1.4.0未満しか受け付けないような指定になっていたのですが、2019/2/4にsqlite3のgemの1.4.0がリリースされたためエラーが出るようになりました。
以下の修正により、1.3.6以上、2.0.0未満のバージョンを受け付けるようになっています。
https://github.com/rails/rails/commit/6d5f2511e6d9b95a8ac8399c234aa6cd074af51d

既に5-2-stableブランチにもマージされているので、次のリリースでは問題が起きなくなっていると思います。

以下のissueとpull requestで議論されています。
https://github.com/rails/rails/issues/35153
https://github.com/rails/rails/pull/35154

133
96
4

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
133
96