2020.10.10 I made a correction from the comment.
Ruby 2.5.7 Rails 5.2.4
gem gem 'rspec-rails', '~> 3.6'
When I wrote the test code in RSpec and executed it, I got the following error.
$ rspec spec/models/tag_spec.rb
WARN: Unresolved specs during Gem::Specification.reset:
diff-lcs (< 2.0, >= 1.2.0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
It's not exactly an error, it seems that I'm being warned of it because there are multiple versions of the same gem, and the test itself was running successfully. However, I can't leave it alone, so I'll solve it.
I referred to this article for the solution. What to do when WARN: Clearing out unresolved specs. Appears in Qiita --Rubygem
First, let's check the gem in question.
$ diff-lcs (< 2.0, >= 1.2.0)
It was pointed out that there are multiple versions of the gem called diff-lcs
, but I don't remember installing this gem myself, so of course it is not mentioned in the Gemfile.
Then, when installing some gem, bundler may have installed it automatically as a dependent gem, so if you check Gemfile.lock
, you can see thatdiff-lcs (1.4) other than the gem dependency of rspec. There was .4)
.
There are two dependent gems installed with rspec, both of which are like diff-lcs (> = 1.2.0, <2.0)
, and the version is not written, so the version of this gem is next I will investigate with a command.
$ gem list -a | grep diff-lcs
diff-lcs (1.4.4, 1.4.2, 1.3)
As a result of investigation, it seems that (1.4.4, 1.4.2, 1.3)
3 versions are installed.
The non-dependent diff-lsc (1.4.4)
is the latest of these, so we'll match the other two, which depend on rspec, to this version.
One thing to note here is that if you install a gem that depends on bundler, if you change the version of the dependent gem easily, other gems that are dependent on it may malfunction.
In this case, the version of diff-lcs (<2.0,> = 1.2.0)
, which depends on rspec, was written as" 1.2.0 or more, less than 2.0 ", so it is the latest (in this time). I came to the conclusion that there is no problem even if I upgrade the version of 1.4.4.
Next, execute the command written on the reference site.
$ gem cleanup
And
$ bundle install
The warning text has now disappeared.
I will excerpt from this comment.
$ bundle exec rspec (Executable file specification)
When you do, bundler will automatically recognize the dependencies described in the Gemfile.
When the dependency becomes complicated and multiple versions are absolutely necessary, this method is the only way because it cannot be combined into the latest version mentioned above.
In my case, there was another warning message in addition to this, so please see the next article for that ヽ (; ▽ ;) ノ Qiita-[Ruby on Rails] I get a warning when running RSpec because gem'chromedriver-helper' is deprecated.
If you have any questions, differences in interpretation, or discomfort in the description method, we would appreciate it if you could point them out in the comments.
Thank you for reading until the end.
I have published the files I actually use on my GitHub, so I hope you can refer to that as well! GitHub - MasaoSasaki/matchi
Other What to do when WARN: Clearing out unresolved specs. Appears in Qiita --Rubygem YoheiIsokawa-[Rails] How to write Gemfile version specification
Recommended Posts