simplecov icon indicating copy to clipboard operation
simplecov copied to clipboard

Calling Simplecov.start more than once raises an exception

Open dillonwelch opened this issue 4 years ago • 6 comments

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.

dillonwelch avatar Oct 29 '21 00:10 dillonwelch

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.

luke-hill avatar Oct 27 '22 12:10 luke-hill

Any update on this? I experience the same problem with Ruby 3.2.1.

yegor256 avatar Mar 22 '23 11:03 yegor256

I'm also experiencing the same problem with Ruby 3.1.4

senemsoy avatar Apr 03 '23 18:04 senemsoy

Face it with Ruby 3.1.4 on version (0.21.2) Upgrading to simplecov (0.22.0) solved it

nicolaep avatar Apr 18 '23 11:04 nicolaep

I can confirm that upgrading to 0.22.0 solves it, so this issue could be probably be closed.

mykhi avatar Jan 12 '24 22:01 mykhi