$ bundle exec rake db:reset command raising couldn't drop db/development.sqlite3

WowBow picture WowBow · Apr 24, 2012 · Viewed 17.4k times · Source

I tried to run $ bundle exec rake db:reset and found the following on console

Couldn't drop db/development.sqlite3 : #<Errno::EACCES: Permission denied - c:/sample_app/db/development.sqlite3>
db/development.sqlite3 already exists
-- create_table("users", {:force=>true})
   -> 0.3940s
-- add_index("users", ["email"], {:name=>"index_users_on_email", :unique=>true})

   -> 0.1280s
-- initialize_schema_migrations_table()
   -> 0.0010s
-- assume_migrated_upto_version(20120419034627, ["c:/sample_app/db/migrate
"])
   -> 0.0040s

How can I solve it?

Edit I was following a tutorial and it tells me to run the above command to delete all the data from the database safely. And I am also using admin account.

Answer

htanata picture htanata · Apr 24, 2012

When you do db:reset, it's running db:drop and db:setup in sequence. Your error message indicates that db/development.sqlite couldn't be deleted.

If you're on Windows, maybe you need to stop your Rails server and console. Otherwise, figure out what's preventing the file from being deleted. It could be permission problem. A reboot may solve the problem too.