Calling Simplecov.start more than once raises an exception
It looks like ruby-head made an update a few days ago that caused Coverage.start to raise an exception if you call it more than once. Naturally, this will also cause SimpleCov.start to raise the same exception.
Here is an example of what happens:
Stopped processing SimpleCov as a previous error not related to SimpleCov has been detected
/home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov.rb:354:in `start': coverage measurement is already setup (RuntimeError)
from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov.rb:354:in `start_coverage_with_criteria'
from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov.rb:343:in `start_coverage_measurement'
from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov.rb:59:in `start'
from /home/runner/work/devise-security/devise-security/test/test_helper.rb:26:in `<top (required)>'
from /home/runner/work/devise-security/devise-security/test/test_compatibility.rb:3:in `require'
from /home/runner/work/devise-security/devise-security/test/test_compatibility.rb:3:in `<top (required)>'
from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `require'
from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `block in <main>'
from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `select'
from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `<main>'
You can see at https://github.com/devise-security/devise-security/pull/343 where the issue was fixed once I updated to only do this once.
Is there a way that SimpleCov can wrap this into something more presentable so that the fix is clear? It took me digging into the ruby source code to figure out why it only failed in Ruby 3.1 (aka ruby-head)
Also, the unstable tests on this repo appear to be failing? Doesn't seem related based on the error but I figure I'd point it out.
I only call Simplecov.start once in my CI, but it seems to still throw this error. I just added 3.1 to my run matrix.
See https://github.com/site-prism/site_prism/actions/runs/3337538167/jobs/5524008967
I "do" require simplecov in 2 diff places (rspec and cucumber), but this is just for redundancy I believed.
Any update on this? I experience the same problem with Ruby 3.2.1.
I'm also experiencing the same problem with Ruby 3.1.4
Face it with Ruby 3.1.4 on version (0.21.2) Upgrading to simplecov (0.22.0) solved it
I can confirm that upgrading to 0.22.0 solves it, so this issue could be probably be closed.