Saturday, February 28, 2009

Permission denied - db/test.sqlite3

I'm investigating creating a plugin for Redmine and having a good old time when I decide to clear out the test database:

C:\dev\redmine>rake db:test:purge
(in C:/dev/redmine)
rake aborted!
Permission denied - db/test.sqlite3

Boo! 

I don't know what made me think of it but I tried unsetting my RAILS_ENV environment variable (I had it set to "test"):

C:\dev\redmine>set rails_env=

C:\dev\redmine>rake db:test:purge
(in C:/dev/redmine)

C:\dev\redmine>

Hurrah!

5 comments :

  1. Problem still exists for me in Ruby 1.8.7. Permission denied when using SQLite 3, but only when the target is test.

    rake db:test:purge may work, but db:test:prepare is not.

    ReplyDelete
  2. @Titus, do you have a console open in the test environment?

    http://stackoverflow.com/questions/1234471/rails-rake-testfunctionals-cannot-access-db-sqlite3-on-winxp

    ReplyDelete
  3. unsetting RAILS_ENV worked for me on rake db:test:prepare. Never would have found this without your post -- Thanks

    ReplyDelete
  4. Here is another case when apatana locks the db and causes the error. See post: http://www.gyrotechie.com/2009/01/permissions-problem-with-rake-on-xp/

    ReplyDelete
  5. yep, this 100% works in windows. Amazing fix/hack. Yet so bad on the part of whoever caused this obscure issue.

    ReplyDelete