YardMap#spec_for_require: Get gem with version from bundle #509
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is another stab at problem described in #508. Which basically makes solargraph work better when being run outside bundle (without
bundle exec
)Why run solargraph outside bundle anyway?
Legacy projects usually have gems with old gem dependencies. This means that we want to use the latest solargraph version, we can't, because one of its depedencies cannot be satisfied:
Usually upgrading deps in such projects is a huge undertaking, which often does not justify installing solargraph
What this fix does?
We already know the version of each gem from the bundle from
YardMap#process_gemsets
. So instead of fetching gem specification usingGem::Specification.find_by_name(name)
(which, while in bundler will resolve to the only and correct version of the gem), we can fetch it usingGem::Specification.find_by_name(name, version)
, which resolve to correct gem version even when solargraph runs outside bundleImpact
Before fix in a sample project with Rails annotations:
After fix in a sample project