Specified sqlite3 gem not loaded

2019-05-31 01:25发布

问题:

Although I am relatively new to Ruby on Rails, I have been developing apps for a short while now. The problem I seem to have is when I create a new rails app (locally / using c9) I seem to be getting this error when I start up the apache server

"Specified 'sqlite3' for database adapter, but the gem is not loaded. 
Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the 
minimum required by ActiveRecord)"

In My Gem file I can see that the sqlite3 gem is present.

I have tried uninstalling and reinstalling the sqlite3 gem trying both versions 1.3.13 as well as 1.4.0 but with no success.

I have also 'git cloned' one of my older completed apps from git hub on to my 'local' and c9 development environments and will work perfectly until I bundle update, Then I get the same error message!

Can anyone give me some advise? I am aware that this problem was brought up a few years back but was wondering if anyone has encountered this recently and if/how they resolved this?

Many Thanks

回答1:

It is very strange but two weeks ago I also got the same issue, and when I initiate my rails new project it put gem 'sqlite3' without any version number, and I get the same error. So I played a lot on brew so I thought it is an issue due to that playing with SQLite, somehow I came to know that maybe my Sqlite3 gem has an issue. And I noticed it is loading 1.4 version of it.

I did following change and it worked.

gem 'sqlite3', '~> 1.3.11'

Just in case if someone searching answer of this question, as it resolved issue of question asker.