Absurdim
Absurdim

Reputation: 233

rake aborted! ActiveRecord::StatementInvalid: SQLite3::ReadOnlyException

I am trying to deploy an app to EC2 following this tutorial. When I run rake db:migrate, I get this error:

rake aborted!                                                                                                                                                                         
ActiveRecord::StatementInvalid: SQLite3::ReadOnlyException: attempt to write a readonly database: CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 

when running ls -l

total 16                                                                                                                                                                        
-rw-r--r-- 1 root   root      0 Apr 16 03:55 development.sqlite3                                                                                                                
drwxrwxr-x 2 ubuntu ubuntu 4096 Apr 16 03:48 migrate                                                                                                                            
-rw-rw-r-- 1 ubuntu ubuntu 5989 Apr 16 03:48 schema.rb                                                                                                                          
-rw-rw-r-- 1 ubuntu ubuntu  345 Apr 16 03:48 seeds.rb                                                                                                                           
-rw-r--r-- 1 ubuntu ubuntu    0 Apr 16 12:28 test.sqlite3

Upvotes: 1

Views: 1711

Answers (2)

Wellington1993
Wellington1993

Reputation: 369

Just a little adjust to the Peter response, making user dynamically, and changing permissions of other files inside the same project recursively:

sudo chown -R $USER .

Upvotes: 0

Peter Klipfel
Peter Klipfel

Reputation: 5178

If you're running in development mode on the server (generally not what you want to do, but can be useful for learning), you need to modify the permissions of your sqlite database. So, if you're running an ubuntu AMI on EC2 (which I think you are) run sudo chown ubuntu:ubuntu development.sqlite3 and sudo chown ubuntu:ubuntu test.sqlite3.

This changes the user who owns the file (chown = change owner) to the ubuntu user.

Upvotes: 4

Related Questions