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


#1

Hi all, I seem to have run into this issue when trying migrate the database. I’m using Ubuntu and I’m sure I followed all the steps correctly so far.

user:~/odin_on_rails/my_first_rails_app2$ rails db:migrate > …/log.txt
rails aborted!
LoadError: 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.
/home/user/odin_on_rails/my_first_rails_app2/bin/rails:9:in <top (required)>' /home/user/odin_on_rails/my_first_rails_app2/bin/spring:15:in<top (required)>’
bin/rails:3:in load' bin/rails:3:in

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/user/odin_on_rails/my_first_rails_app2/bin/rails:9:in <top (required)>' /home/user/odin_on_rails/my_first_rails_app2/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)


Localhost:3000/cars doesn't appear to be working. it's just a bunch of code. Please help
#2

Can you post the contents of your Gemfile?

It looks like your Gemfile is specifying a version of sqlite3 up to 1.3.6 (but not above), but you already (at that point) have 1.4.0 activated.


#3

I have same problem


#4

rails aborted!
LoadError: 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.
/home/juan/odin_on_rails/RailsaAPP/bin/rails:9:in <top (required)>' /home/juan/odin_on_rails/RailsaAPP/bin/spring:15:in<top (required)>’
bin/rails:3:in load' bin/rails:3:in

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/juan/odin_on_rails/RailsaAPP/bin/rails:9:in <top (required)>' /home/juan/odin_on_rails/RailsaAPP/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)


#5


#6

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.


#7

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


#8

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.


#9

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
#10

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
#11

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

Thanks @1stevengrant !!


#12

Thank you! :smile:


#13

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.


#14

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.


#15

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)


#16

@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.


#17

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


#18

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


#19

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!


#20

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