Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

ruby on rails - bundle exec rake test:models throws Errno::EACCES: Permission denied

I am doing the draft version of the railstutorial, when I try to run bundle exec rake test:models I get this error message:

rake aborted!
Errno::EACCES: Permission denied - C:/Users/Alex/Desktop/Workspace/Rails/sample_
app/db/test.sqlite3
C:/Users/Alex/Desktop/Workspace/Rails/sample_app/test/test_helper.rb:3:in `<top
(required)>'
C:/Users/Alex/Desktop/Workspace/Rails/sample_app/test/helpers/application_helper
_test.rb:1:in `<top (required)>'
Tasks: TOP => test:run => test:units
(See full trace by running task with --trace)

With --trace:

** Invoke test (first_time)
** Execute test
** Invoke test:run (first_time)
** Invoke test:units (first_time)
** Invoke test:prepare (first_time)
** Execute test:prepare
** Execute test:units
rake aborted!
Errno::EACCES: Permission denied - C:/Users/Alex/Desktop/Workspace/Rails/sample_
app/db/test.sqlite3
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:1432:in `unlink'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:1432:in `block in remove
_file'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:1440:in `platform_suppor
t'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:1431:in `remove_file'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:785:in `remove_file'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:563:in `block in rm'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:562:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:562:in `rm'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/sqlite_database_tasks.rb:22:in `drop'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/sqlite_database_tasks.rb:26:in `purge'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:159:in `purge'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:201:in `load_schema_for'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:216:in `block in load_schema_current'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:255:in `block in each_current_configurat
ion'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:254:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:254:in `each_current_configuration'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:215:in `load_schema_current'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:402:in `load_schema_if_pending!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:409:in `block in maintain_test_schema!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:637:in `suppress_messages'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:414:in `method_missing'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:409:in `maintain_test_schema!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_help.rb:19:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `block in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:233:in `load_dependency'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/Users/Alex/Desktop/Workspace/Rails/sample_app/test/test_helper.rb:3:in `<top
(required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `block in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:233:in `load_dependency'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/Users/Alex/Desktop/Workspace/Rails/sample_app/test/helpers/application_helper
_test.rb:1:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `block in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:233:in `load_dependency'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:114:in `block (3 levels) in define'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:114:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:114:in `block (2 levels) in define'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:113:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:113:in `block in define'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:240:in `call'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:240:in `block in execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:235:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:235:in `execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:179:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:201:in `block in invoke_prerequisites'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:199:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:199:in `invoke_prerequisites'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:178:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:165:in `invoke'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:20:in `invoke_rake_task'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/testing.rake:8:in `block in <top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:240:in `call'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:240:in `block in execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:235:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:235:in `execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:179:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:165:in `invoke'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:150:in `invoke_task'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `block in top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:115:in `run_with_threads'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:100:in `top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:78:in `block in run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:176:in `standard_exception_handling'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:75:in `run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/bin/rake:33:in
`<top (required)>'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `load'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `<main>'
Tasks: TOP => test:run => test:units

I have tried checking the permissions on my db folder, and also tried to restart everything. I am using rails version 4.2.0beta1 on windows. The problem started when I made the "User" model. I tried rolling back and migrating up again as well.

Edit: It seems that my test database is corrupted in some way. If I change the /config/database.yml test: to /db/development.sqlite the tests work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I deleted the old test.sqlite3 and replaced it with a copy of development.sqlite3 and renamed it test.sqlite3, this seems to have solved the problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...