I got an "ActionView :: Template :: Error: Permission denied" error in the test of 3.3.1 of Rails tutorial 6th edition, so I solved it.

What is the environment?

What happened?

When I ran the rails test command in Listing 3.15 in the Rails Tutorial (https://railstutorial.jp/chapters/static_pages?version=6.0#sec-our_first_test), I got the following error ①:

Error ①


D:\Programming\RubyOnRails\sample_app2>rails test
Run options: --seed 42827

# Running:

E

Error:
StaticPagesControllerTest#test_should_get_home:
ActionView::Template::Error: Permission denied @ rb_file_s_rename - (D:/Programming/RubyOnRails/sample_app2/tmp/cache/assets/sprockets/v4.0.0/6p/6p5srKo-CqopTzauMxsxGBdnpUciiPghSY6oKN4-uVY.cache.15640.1380.291914, D:/Programming/RubyOnRails/sample_app2/tmp/cache/assets/sprockets/v4.0.0/6p/6p5srKo-CqopTzauMxsxGBdnpUciiPghSY6oKN4-uVY.cache)
    app/views/layouts/application.html.erb:9
    test/controllers/static_pages_controller_test.rb:5:in `block in <class:StaticPagesControllerTest>'


rails test test/controllers/static_pages_controller_test.rb:4

.

Finished in 0.148240s, 13.4916 runs/s, 6.7458 assertions/s.
2 runs, 1 assertions, 0 failures, 1 errors, 0 skips

What is the solution?

Change the relevant part in test_helper.rb toparallelize (workers: 1).

test\test_helper.rb


class ActiveSupport::TestCase
  # Run tests in parallel with specified workers
  parallelize(workers: 1) #here

What did you do to solve it?

I tried the command by referring to "Ruby on Rails Tutorial Troublesome Notes on Implementation on Windows" found by searching for error messages, but the rails assets: precompile command is as follows. I got an error ②.

Error ②


D:\Programming\RubyOnRails\sample_app2>rails assets:precompile
rails aborted!
Errno::ENOEXEC: Exec format error - D:/Programming/RubyOnRails/sample_app2/bin/yarn --version

Tasks: TOP => assets:precompile => yarn:install
(See full trace by running task with --trace)

I tried executing the rails yarn: install command and checking it for a long time, but it seems that I can not handle it, so I decided to give up on solving this error ② for the time being. (Caused by trying to execute a command with bin/yarn ...?)

I thought that it should be given access rights because it is Permission denied, so I allowed all users (groups) to have full control under the tmp folder from Explorer, but error ① was still not fixed.

Similar to the above, if there is a problem with access rights, I thought that I should execute the command with administrator privileges, and I searched for keywords such as "Run as Ruby administrator" and found "Permission denied when gem install with Ruby" "Solution when it appears", I ran the Ruby command prompt as an administrator and typed the rails test command, but error ① was not fixed.

Notice that one of the two tests (should get help) is assertions, comment out should get help in static_pages_controller_test.rb and just should get home I tested it and found no errors. ** In other words, I notice that I am getting an error only when I do two tests at the same time. ** ** When I was researching various things in 1., I remembered that I saw a description that Rails tests are done in parallel to shorten the test time by default, so I searched for keywords such as "Rails test parallel". I found "Rails Testing Guide". When I changed the relevant part in test_helper.rb toparallelize (workers: 1)with reference to 3.1 here, error ① disappeared.

that's all

Recommended Posts

I got an "ActionView :: Template :: Error: Permission denied" error in the test of 3.3.1 of Rails tutorial 6th edition, so I solved it.
[Ruby on Rails Tutorial] Error in the test in Chapter 3
[Action View :: Missing Template] I didn't understand the meaning of the error statement, so I looked it up.
I got a Permission Denied error when I put Laravel in Docker
I don't see an error in Rails bundle install ... the solution
[For beginners] Build the environment for Ruby on Rails Tutorial 4th Edition (Rails 5.1) in less than an hour!
An error occurred in the free course of RubyOnRails Udemy, solved it, and went through to the end
Rails tutorial Resolved an error deploying to Heroku, so note the solution
Rails tutorial (6th edition) Background operation of the posting function of the micro post
I built a CentOS 8 environment with Vagrant and tried to sync_folder, but I got an error, so I solved it.
I used it without knowing the O / R mapping of rails, so I checked it.
I rewrote the Rails tutorial test with RSpec
Where I got stuck in today's "rails tutorial" (2020/10/08)
Where I got stuck in today's "rails tutorial" (2020/10/06)
Where I got stuck in today's "rails tutorial" (2020/10/04)
Where I got stuck in today's "rails tutorial" (2020/10/07)
Webdrivers :: BrowserNotFound: Failed to find Chrome binary. When I was trying to test E2E with Docker + Rails for the first time, I got stuck in an error.
[JUnit] I suddenly got an initialization Error in the JUnit test that worked normally until the day before; background and solution memorandum
Rails tutorial (6th edition) Background operation of profile editing
I got an error "undefined method` create'" in RSpec
Rails tutorial (6th edition) Background operation of login function
After posting an article with Rails Simple Calendar, I want to reflect it in the calendar.
[RSpec] When I tested the view file that used the helper method, I got ActionView :: Template :: Error :. ..
I got stuck in launching Unreal Enigine 4 on an AWS Ubuntu instance, so I summarized it
Rails tutorial (6th edition) Background operation of password reset function
I tried to make the "Select File" button of the sample application created in the Rails tutorial cool
Can't I use RXTX? Is there an alternative?
[Mockito] 3.2.4 → 3.3.x, but I got an error (Iketenai)
I got an error when I ran rake routes.
How to deal with No template for interactive request
I got an error "undefined method` create'" in RSpec
When I bcrypt with node + docker, I got an error
There is no nil! However, "fatal error: unexpectedly found nil while unwrapping an Optional value"
I got an error when using nextInt, nextLine and substring.
I got the error "Calling brew cask install is disabled!"
I want to make the frame of the text box red when there is an input error
I got an error and couldn't push! !! [error: failed to push some refs to]
Is there no type in Ruby?
Initial value when there is no form object property in Spring request
gradle's mybatis-generator-plugin says there is no MapperAnnotationPlugin
I got an "ActionView :: Template :: Error: Permission denied" error in the test of 3.3.1 of Rails tutorial 6th edition, so I solved it.