Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

fix GemNotFound message in Resolver #3566

Closed
wants to merge 2 commits into from
Closed

Conversation

sealocal
Copy link
Contributor

Fixes #3564 (Beginner-friendly error message for misspelled or non-existent gem names).

Feedback from anyone is welcome.

@@ -324,8 +324,8 @@ def verify_gemfile_dependencies_are_found!(requirements)
end
else
message = "Could not find gem '#{requirement}' "
if @index.source_types.include?(Bundler::Source::Rubygems)
message << "in any of the gem sources listed in your Gemfile."
if Bundler.definition.has_rubygems_remotes?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer we didn't reference the Bundler.definition when not necessary, as it makes this method reliant on global state

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. So, perhaps Index#source_types should be re-implemented?

I don't understand how to find the Gemfile's sources from @index. I was thinking @index.sources.each {|source| source.sources} might be helpful, but after experimentation any source's source seems to always be empty.

Another simpler solution would be to remove this conditional completely so that the message here is always in any of the gem sources listed in your Gemfile or installed on this machine..

@indirect
Copy link
Member

It is extremely uncommon to have zero sources, so I am fine with changing the hardcoded message.

@sealocal
Copy link
Contributor Author

@indirect When you say to change the hardcoded message, do you mean that removing the conditional on line 327 of Resolver would be reasonable?

@indirect
Copy link
Member

yes, I think removing the conditional makes sense.

@indirect
Copy link
Member

Cherry-picked into 1-9-stable as dc442f4 and 70262b2. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Beginner-friendly error message for misspelled or non-existent gem names
3 participants