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

17,845

Solution 1

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.

Solution 2

Have been trying to resolve the same issue. Stopping Rails Server on Windows didn't help, but restarting the whole environment did the trick, bundle exec rake db:reset went through, but be sure not to start your server before that as it will call the same error. Continue with

$ bundle exec rake db:reset
$ bundle exec rake db:populate
$ bundle exec rake test:prepare

and start Rails Server after that.

Solution 3

I know this is an old post, but I just had this problem (continued sqlite3 issues with Windows), and while rebooting, shutting the command line, and stopping the server didn't work, I did manage to solve it by actually running each of the commands htanta mentioned above sequentially: 1. bundle exec rake db:drop 2. bundle exec rake db:create 3. bundle exec rake db:migrate

If db:reset is only these commands anyway, I don't understand why it doesn't work but the individual commands do?

Share:
17,845
WowBow
Author by

WowBow

Updated on June 12, 2022

Comments

  • WowBow
    WowBow almost 2 years

    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.

  • WowBow
    WowBow about 12 years
    I restarted everything that uses rails resource and everything is fine now.
  • Shawn
    Shawn almost 12 years
    Had the same problem, stopping the rails server was all I needed to do. Thanks!
  • David T
    David T over 10 years
    see my comment above. try db:migrate:reset to run all of those commands.
  • Jaime
    Jaime about 10 years
    Thank you, @grist. Breaking up the commands worked when nothing else would.
  • muhnizar
    muhnizar almost 10 years
    this answer is correct! I had the same problem and stopping the server for awhile make the command works.