Ruby on Rails - “Add 'gem sqlite3'' to

2020-01-31 03:07发布

I'm a complete n00b on Rails with only beginner knowledge of Ruby. I plan on studying Ruby more before I really learn Rails, but I'm waayy too curious for my own good.

Anyway, I was following the tutorial, but I got stuck when it said to type "rails server" in the blog directory. It states, "Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile." So I quit the server, installed sqlite3, reinstated the server...only to get this message again. sqlite3 doesn't show up when I do "gem list", but I do see the folder in my Root Ruby directory.

If it helps, I got Ruby 2.0, Rails 4.0, sqlite3 1.3.7

I apologize if this was answered already somewhere else, but I couldn't find anything in the vast database that is stackoverflow. I would appreciate any patience that you are willing to provide.

Thank you very much! hewhocomes

11条回答
太酷不给撩
2楼-- · 2020-01-31 03:34

In my case, this error "Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile." message showed up, when I ran rails server right after I generated a fresh rails app. It was with Rails version 4.1.16 (Ruby version 2.3.1)

gem 'sqlite3', '~> 1.3.0'

This line in Gemfile removed the error message. I think new sqlite gem (version 1.4) has a conflict with old rails (version 4.1) but I didn't see any related issue on their Github repository. I'm adding this answer here because it might help anybody experiencing the same situation I'm in.

查看更多
smile是对你的礼貌
3楼-- · 2020-01-31 03:38

For me it helped to put version after gem 'sqlite3' in gemfile, so it became gem 'sqlite3', '1.3.7'. Previously I tried to compile sqlite3, updated gem, etc... Rails wasn't able to "accept" it still, so finally defining the version helped.

查看更多
地球回转人心会变
4楼-- · 2020-01-31 03:41

I'd the same problem on a x64 win 7.

Solution (for me):

1) Install sqlite3

gem install sqlite3

2) Check the installed version

gem list sqlite3

It gives me: sqlite3 (1.3.8 x64-mingw32)

3) Modify the Gemfile.lock

I change "sqlite3 (1.3.8-x86-mingw32)" by "sqlite3 (1.3.8-x64-mingw32)

It works :) Note that you to need add a "-" between the version number and the x64 in the Gemfile.lock

Xmass

查看更多
等我变得足够好
5楼-- · 2020-01-31 03:43

I had this error appear with the same version of Ruby / Rails / SQLite that you specified in your question even after confirming that my gemfile has gem 'sqlite3'. I don't know what OS you have (which is why you were down-voted probably) but I am using Windows 7 x64.

In order to get the gem to be installed in my Rails application, I needed to edit the Gemfile.lock file to replace sqlite3 (1.3.7-x86-mingw32) with sqlite3 (1.3.7)

Then, after running bundle install I finally see in the output

Using sqlite3 (1.3.7)

Upon running rails server, I (finally) see the "Welcome aboard" page.

查看更多
手持菜刀,她持情操
6楼-- · 2020-01-31 03:44

Just add this line to your Gemfile, which is located in the root folder of your application

  gem 'sqlite3'
查看更多
登录 后发表回答