New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the config loader Bundler-aware #7983
Conversation
9e45c36
to
db296ba
Compare
I can think of a couple open questions that should be answered before merging:
|
Good points.
|
This proposal looks good to me. OTOH, I'm worried about it doesn't work with Bundler 1.2.0(Bundler's patch version is not investigated). Bundler 2.1.4
Bundler 1.3.0
Bundler 1.2.0
|
I like this suggestion! |
@koic It does work! 😃 The Gemfile you ran your test on apparently isn't compatible with Bundler 1.2.0. When everything aligns just right (ruby version, Bundler version, and Gemfile syntax):
I don't think catching
@bbatsov Do you have any suggestion how to succinctly explain these potential edge-cases? 🙂 |
Before this change, when inheriting a configuration from a gem, rubocop: 1. would fail to find it, if the gem specified in the Gemfile has a `path` or `git` option (because rubygems is unaware of those gems) 2. would always load the config of the latest installed version of a gem, regardless of the version specified in the Gemfile This commit changes that, so if executed in the context of Bundler (`defined?(Bundler)`) it will first try to get the gem path via Bundler, and fallback to the previous `Gem::Specification` path when not found. This solves the two mentioned issues while maintaining the possibility to run rubocop in a globally installed context, i.e. without Bundler.
Something like "Require Bundler X or newer" perhaps? |
This PR doesn't require Bundler, but if we're talking version requirement of an optional integration that it enables – I've tried the oldest version that's mentioned in bundler's changelog (0.9.5 from 2010) that snippet still worked, so I'm now even more confident that we're safe on that front. 😃 |
No need to fret over this further then. :-) |
Before this change, when inheriting a configuration from a gem, rubocop:
path
orgit
option (because rubygems is unaware of those gems)This commit changes that, so if executed in the context of Bundler (
defined?(Bundler)
) it will first try to get the gem path via Bundler, and fallback to the previousGem::Specification
path when not found.This solves the two mentioned issues while maintaining the possibility to run rubocop in a globally installed context, i.e. without Bundler.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.