Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 SQLite3::ReadOnlyException: attempt to write a readonly database

I keep receiving the error SQLite3::ReadOnlyException: attempt to write a readonly database: UPDATE "users" SET "current_sign_in_at" = ?, "sign_in_count" = ?, "updated_at" = ? WHERE "users"."id" = ? when trying to sign into my Rails 4 app which uses the devise gem.

I figured it has something to do with permissions on the dev db so checked out the permissions of the dir first, it has a + tacked onto the end which after some googling still couldn't figure out what it's doing.

-rw-r--r--   1 a36971  staff   2.1K 24 Jan 20:16 Gemfile
-rw-r--r--   1 a36971  staff   5.7K 24 Jan 20:16 Gemfile.lock
-rw-r--r--   1 a36971  staff    47B  7 Jan 22:31 README.md
-rw-r--r--+  1 root    staff   249B  7 Jan 19:57 Rakefile
drwxr-xr-x+  8 root    staff   272B  7 Jan 19:57 app/
drwxr-xr-x+  7 root    staff   238B  7 Jan 19:57 bin/
drwxr-xr-x+ 13 root    staff   442B 22 Jan 20:14 config/
-rw-r--r--+  1 root    staff   153B  7 Jan 19:57 config.ru
drwxr-xr-x+  8 root    staff   272B 26 Jan 10:28 db/
drwxr-xr-x+  4 root    staff   136B  7 Jan 19:57 lib/
drwxr-xr-x+  5 root    staff   170B  8 Jan 15:51 log/
drwxr-xr-x+  7 root    staff   238B  7 Jan 19:57 public/
drwxr-xr-x   7 a36971  staff   238B 17 Jan 22:38 spec/
drwxr-xr-x+  9 root    staff   306B  7 Jan 19:57 test/
drwxr-xr-x+  6 root    staff   204B  7 Jan 20:19 tmp/
drwxr-xr-x+  3 root    staff   102B  7 Jan 19:57 vendor/

After cd ing into the db dir you can see there's nothing wrong with the permissions on the db itself:

-rw-r--r--  1 a36971  staff    44K 26 Jan 09:30 development.sqlite3
drwxr-xr-x  5 a36971  staff   170B 22 Jan 20:14 migrate/
-rw-r--r--  1 a36971  staff   2.2K 22 Jan 20:14 schema.rb
-rw-r--r--  1 a36971  staff   1.2K 25 Jan 23:22 seeds.rb
-rw-r--r--  1 a36971  staff    44K 26 Jan 09:23 test.sqlite3

So my questions are:

a) why is it unable to write to the db when there doesn't appear to be anything wrong with the permissions themselves

b) what does the + mean on mac os?

like image 426
Chris Avatar asked Jan 26 '15 12:01

Chris


1 Answers

a) why is it unable to write to the db when there doesn't appear to be anything wrong with the permissions themselves

My best guess is that the db/ directory is owned by the root user, whereas the db/*.sqlite3 files are owned by user a36971. It may be necessary for the db/ directory to also be owned by user a36971.

Try changing the owner from root to a36971 for the db directory:

sudo chown a36971 db

b) what does the + mean on mac os?

+ sign means there are additional permission details not displayed by the default output from ls -l. Try running ls -le to see the details (source: http://tech.enekochan.com/en/2014/05/29/plus-and-at-symbols-listing-file-permissions-in-mac-os-x/).

like image 147
Eliot Sykes Avatar answered Nov 09 '22 13:11

Eliot Sykes