simplecov-ruby / simplecov-html

HTML formatter for SimpleCov code coverage tool for ruby 1.9+
http://github.com/colszowka/simplecov
MIT License
73 stars 117 forks source link

Fails with `Errno::EACCES: Permission denied @ rb_sysopen` if vendor files are read-only #133

Closed h3xx closed 2 weeks ago

h3xx commented 5 months ago

I think this issue stems from the fact this library does not clear out the coverage directory before it runs. If it simply removed the coverage directory before starting, it should fix this error.

Related issue: #134 -- when this one is fixed, that one will also likely be fixed.

Steps to repro:

rails new --skip-bootsnap temp
cd temp
bundle config set --local path 'vendor'
bundle add simplecov
printf 'require "simplecov"\nSimpleCov.start "rails"\n' >>test/test_helper.rb
chmod -R a-w vendor
bin/rails test
# Run tests again to produce the error
bin/rails test

The second rails test fails with the following error message:

Running 0 tests in a single process (parallelization threshold is 50) Run options: --seed 46566

# Running:

Formatter SimpleCov::Formatter::HTMLFormatter failed with Errno::EACCES: Permission denied @ rb_sysopen - /tmp/ndz.eFIwFv/temp/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc.png (/home/h3xx/.rbenv/versions/3.3.0/lib/ruby/3.3.0/fileutils.rb:2279:in `initialize')

Version info

tomeon commented 5 months ago

Related: https://github.com/simplecov-ruby/simplecov/issues/741