bundle exec rake test:models throws Errno::EACCES: Permission denied

前端 未结 4 1671
囚心锁ツ
囚心锁ツ 2020-12-19 19:41

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:         


        
相关标签:
4条回答
  • 2020-12-19 20:15

    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.

    0 讨论(0)
  • 2020-12-19 20:26

    I noticed this happens if I have one terminal open running the rails server and another terminal to work on. My work Terminal is what gives me the issue when I try to drop or reset a database. I close the server ans try again and it works fine.

    0 讨论(0)
  • 2020-12-19 20:34

    Run rake db:migrate RAILS_ENV=test before running the tests.

    I'm not a rails expert, so I don't know if the test DB should be migrated automatically when migrating the development DB, but this will migrate it, and it resolved my similar problem.

    Note: My OS is Windows 8.1

    0 讨论(0)
  • 2020-12-19 20:38

    Yes, the issue is with Windows. when you read the code for fileutils.rb found in railsinstaller directory. It wants to unlink and want to give permission 700(which is found in unix/linux) but not in windows. so will not work.

    Here is the snippet from the fileutil.rb file.

    def remove_file
      platform_support {
        File.unlink path
      }
    end
    
    def platform_support
      return yield unless fu_windows?
      first_time_p = true
      begin
        yield
      rescue Errno::ENOENT
        raise
      rescue => err
        if first_time_p
          first_time_p = false
          begin
            File.chmod 0700, path()   # Windows does not have symlink
            retry
          rescue SystemCallError
          end
        end
        raise err
      end
    end
    
    0 讨论(0)
提交回复
热议问题