当我在Rails中运行rake db:drop时,权限被拒绝@ unlink_internal

时间:2017-08-23 20:34:00

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 rubygems

运行rake db:droprake db:reset

时出现以下错误

我已尝试在互联网上找到的所有内容,包括重新启动服务器,重新启动计算机,删除development.sqlite3和schema.rb以及重新运行迁移。任何帮助,将不胜感激。我是ROR的新人。提前致谢。我正在使用Rails 5.1.3和Ruby 2.4.1。

** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Invoke db:check_protected_environments (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config
** Execute db:check_protected_environments
** Execute db:drop
** Invoke db:drop:_unsafe (first_time)
** Invoke db:load_config
** Execute db:drop:_unsafe
Permission denied @ unlink_internal - C:/Users/hash/Desktop/Rails_Blog/blog/db/development.sqlite3
Couldn't drop database 'db/development.sqlite3'
rake aborted!
Errno::EACCES: Permission denied @ unlink_internal - C:/Users/hash/Desktop/Rails_Blog/blog/db/development.sqlite3
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1340:in `unlink'
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1340:in `block in remove_file'
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1348:in `platform_support'
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:1339:in `remove_file'
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:703:in `remove_file'
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:506:in `block in rm'
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:505:in `each'
C:/Ruby24-x64/lib/ruby/2.4.0/fileutils.rb:505:in `rm'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/tasks/sqlite_database_tasks.rb:22:in `drop'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:144:in `drop'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:160:in `block in drop_current'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:303:in `each'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/tasks/database_tasks.rb:159:in `drop_current'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
C:/Ruby24-x64/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activerecord-5.1.3/lib/active_record/railties/databases.rake:38:in `block (2 levels) in <top (required)>'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
C:/Ruby24-x64/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
C:/Ruby24-x64/bin/rake:22:in `load'
C:/Ruby24-x64/bin/rake:22:in `<main>'
Tasks: TOP => db:drop:_unsafe

0 个答案:

没有答案