Rubygems: Unresolved specs during Gem::Specification.reset: minitest (~> 5.1)

Created on 28 May 2015  路  15Comments  路  Source: rubygems/rubygems

I wasn't sure where to put this, but I saw a similar issue here(https://github.com/rubygems/rubygems/issues/1070) being discussed and figured it was the right place.

I am running into the following issue:

$ rake test:prepare
WARN: Unresolved specs during Gem::Specification.reset:
      minitest (~> 5.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.

Normally this warning doesn't block the command from running like in the above output, but the warning does show on almost all commands I run which load my environment. I have tried quite a few different fixes to this issue. I have tried using minitest 5.1. Uninstalling/installing my bundle. I've even tried just rebuilding my whole environment. Nothing allows me to prepare test cases though.

I am not sure how to remedy this issue/if there is a remedy. I have prepared a GIST with information about my environment and can update it with whatever information is needed to figure this problem out. I recently updated to Rails 4 and hope there is just some incompatibility I am overlooking. Sorry if this isn't the right place to ask about this, it's a rather ambiguous issue.

https://gist.github.com/shawndeprey/68653f2cae4c140f97d6

Most helpful comment

RVM global gemset was the cause of my issue.

$ gem list minitest

*** LOCAL GEMS ***

minitest (5.10.1, 5.8.3)

gem uninstall minitest was only removing 5.10.x, but rvm @global do gem uninstall minitest removed the 5.8.x.

$ rvm @global do gem uninstall minitest
Successfully uninstalled minitest-5.8.3

All 15 comments

Maybe this will help, I did figure out some incompatibilities which may shed some light on this issue.

rails (= 4.2.1) ruby depends on
      activesupport (= 4.2.1) ruby depends on
        minitest (~> 5.1) ruby

It looks like Rails 4.2.1, the version I am using, depends on minitest 5.1. However, as you will see in the following the latest release version of minitest-rails (2.1.1) depends on minitest 5.4.

minitest-rails (= 2.1.1) ruby depends on
      minitest (~> 5.4) ruby

I can't find a version of minitest-rails which supports the same version of minitest as rails itself, and it seems like this might be the issue. Maybe minitest-rails and rails are technically incompatible in their current release states? Or am I just reading that wrong?

This is the right place! What version of Ruby and RubyGems are you using? What is the output of gem list minitest (without bundle exec)?

Those two should be compatible. If the version is X.Y.Z, then ~> 5.1 means X = 5, Y >= 1, Z = anything. ~> 5.4 means X = 5, Y >= 4, Z = anything. So minitest 5.4.X should work for both.

It seems like something is depending on minitest, and the spec is being activated before bundler has a chance to do it's thing. If you do bundle exec rake test:prepare, do you still get the warning?

Thanks for the quick response, I have been doing some testing based on what you said.

I am using ruby '2.2.2' combined with rubygems-bundler (1.4.4). The output I get from the gem list is the following:

$ gem list minitest

*** LOCAL GEMS ***

minitest (5.6.1, 5.4.3)
minitest-rails (2.1.1)

When I run bundle exec rake test:prepare I do not get the warning, in fact I don't get any output at all. However, the result is also the same as running the command without bundle exec. Does any of that information help?

Sorry, just to be clear: whey you run rake test:prepare, you get the error, but when you run bundle exec rake test:prepare, you don't?

@tenderlove yes, but in both cases the process still doesn't happen. That makes me think the error is just being suppressed.

@tenderlove I think I figured this one out, at least in part. So it looks like the spec reset might have been a red herring to the actual problem. My problem ended up being that my test database wasn't created. I got the idea to just manually create my database after checking out the following thread: https://github.com/rspec/rspec-rails/issues/936

I used the following commands to do it:

RAILS_ENV=test;bundle exec rake db:create;RAILS_ENV=development
RAILS_ENV=test;bundle exec rake db:migrate;RAILS_ENV=development

I then was able to run my tests correctly with the following commands(depending on my use case):

RAILS_ENV=test;bundle exec rake test;RAILS_ENV=development
RAILS_ENV=test;bundle exec m test/functional/controllers/api/v4/companies_controller_test.rb:13;RAILS_ENV=development

All this is to say I think the red herring means this issue can be closed. I am not sure if I just missed something in the way you are supposed to configure your test environment in rails 4, but in any case the gem spec isn't the issue. Thanks for the help.

I was getting this same warning message too and thought I'd share what fixed it (for me).

Apparently, my issue was I had different versions of the same gem(s) and Rspec wasn't sure which to use. All I did was gem cleanup with the name of the gems popping up in the warning.

Ex1: gem cleanup minitest
Ex2: gem cleanup loofah

Once that was done, the warning went away. Hope this helps! :)

Thanks for the follow up btw SRod86. Had the same error.

@SRod86 your approach solved it for me!

There's another un/common pathology when using bundler with bundled projects _and_ making the mistake of requiring bundled gems _before_ require 'bundler/setup' can result in output similar to the following:

...
WARN: Unresolved specs during Gem::Specification.reset:
      minitest (~> 5.1)
      rake (>= 0.8.7)
WARN: Clearing out unresolved specs.
...

Solution: require bundled gems _after_ bundler/setup, i.e., for Rails: require gems only _after_ require 'bundler/setup' in config/boot.rb or later.

@SRod86 . Your approach helped resolve a similar issue I was facing

WARN: Unresolved specs during Gem::Specification.reset:
json_pure (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
bash-3.2# gem cleanup json_pure
Cleaning up installed gems...
Attempting to uninstall json_pure-1.8.1
Successfully uninstalled json_pure-1.8.1
Clean Up Complete

I ran into a similar problem with the same warning message. The problem was that I had both minitest-5.8.4 and minitest-5.9.0 installed. After running gem cleanup minitest to remove 5.8.4, rspec kept complaining that it was missing and bundling would reinstall it despite 5.9.0 also installed. In the end I was forced to run gem uninstall minitest to remove both versions and re-bundle.

I was never able to determine what was requiring 5.8.x specifically since no version was explicitly listed in my Gemfile and all of the dependencies I was able to find showed '~> 5.8' at the highest or something else that 5.9.0 should have met.

RVM global gemset was the cause of my issue.

$ gem list minitest

*** LOCAL GEMS ***

minitest (5.10.1, 5.8.3)

gem uninstall minitest was only removing 5.10.x, but rvm @global do gem uninstall minitest removed the 5.8.x.

$ rvm @global do gem uninstall minitest
Successfully uninstalled minitest-5.8.3

Cleanup was not doing the trick but rvm @global do gem uninstall minitest solved it for me thank you @kpheasey!

I used bundle clean --force and then ran bundle install to reinstall gems. Fixed the issue here.

Was this page helpful?
0 / 5 - 0 ratings