Sqlite3 error when trying to migrate the database (2.3 First rails app)



Your Gemfile looks fine to me (in terms of sqlite).

I think we need someone with more Rails experience than me. I’m sure you’ll get some advice soon :wink:

P.S. I might try gem install sqlite3 (perhaps with gem uninstall sqlite3 first) and bundle install again, just to see if that fixes it, but I have a feeling it won’t.


I get the same error. This sucks. :joy:


I’m here as I’m trying to help my wife who has just started to dig into TOP.

It’s been a long time since I looked at Rails (I’m a JavaScript / PHP dev myself), but this was exactly the kind of thing I ran into years ago and it turned me off the framework and led me to using Laravel.

It shouldn’t be this hard to configure a simple dev environment.

I’m watching for any resolutions to this issue.


Having just tried to setup my own Mac with the guide here on TOP, this worked for me:

Open the Gemfile inside my_first_rails_app and change gem 'sqlite3' to gem 'sqlite3', '~> 1.3.6'

Save the file.

From Terminal, run bundle install

Then, run rails generate scaffold car make:string model:string year:integer then you should see something like

First Rails Application (Part 2.3) Error: rails generate scaffold car make:string model:string year:integer
Error rails db:migrate

I tried this and I got the same output as above, but when running the server with rails server and opening the page http://localhost:3000/cars, I get the following error message:

Clearly I must be missing something.

First Rails Application
I am having issues with generating templates from Rails
Eror sqlite3

Some success! I overcame the issue by running the command rails db:migrate after:

Thanks @1stevengrant !!


Thank you! :smile:


You’re welcome. As I said, this exact thing put me off years ago and, in my humble opinion, why PHP is a language to learn as a beginner because it’s much simpler to setup.


When you say “Open the Gemfile inside my_first_rails_app”, what is the command to do that? I’m struggling to find an answer anywhere…lol. I’m VERY new at this. Thanks for your help.


me too
Caused by:
Gem::LoadError: can’t activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile.
/home/cesar/odin_on_rails/my_third_rails_app/bin/rails:9:in <top (required)>' /home/cesar/odin_on_rails/my_third_rails_app/bin/spring:15:in<top (required)>’
bin/rails:3:in load' bin/rails:3:in
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)


@bbates22 the answer (as with most development things) is it depends. Are you on Mac, Linux or Windows?

You need to find that file in your code editor, open and edit it.


I’m using Xubuntu…it appears that sqlite3 may not have even installed w/ the bundler. Fascinating.


I think I may have figured it out. I’ll come back if I’m still stuck. Thank you!


I am working on a Mac and have not been able to find the file in my code editor. If you know the commands for this, it would be of great help! Thanks!

Nevermind, figured it out! Fixed my error, thanks man!


I was having the same issue, but @1stevengrant’s solution got it working. Thanks!


I’m using Ubuntu 18.04 and ran into the same problem but @1stevengrant’s solution also worked for me.
Thank you!


Hi @bbates22, I’m using Ubuntu and was able to edit the Gemfile by:

  1. using cd to enter the directory that the app is in (for me it was cd odin_on_rails/my_first_rails_app)
  2. using ls -a to list the files in the directory and make sure the Gemfile was present
  3. using xdg-open Gemfile to open the Gemfile (you may need to use a different command depending on your OS)
  4. in the Gemfile, use “ctrl+f” to locate 'sqlite3' and change it as @1stevengrant suggested

hope this helps


I opened the my_first_rails_app and have opened the gem file document. What specifically do I change?


as described above, by @1stevengrant

change gem 'sqlite3' to gem 'sqlite3', '~> 1.3.6' in the Gemfile (and save the file)

then run bundle install again.