bundler-explain 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +83 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bundler-explain.gemspec +29 -0
- data/lib/bundler/explain.rb +13 -0
- data/lib/bundler/explain/overrides.rb +39 -0
- data/lib/bundler/explain/source.rb +168 -0
- data/lib/bundler/explain/version.rb +5 -0
- data/plugins.rb +2 -0
- data/test.rb +39 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 71233be6dbcd5f33d7b78ba62fd540ab48ea6d678847f5e98c254f96771a13dd
|
4
|
+
data.tar.gz: 8178fbaf874bd939475a7f27fdbc0c5a61779d7a1f56867f9fd059ce7da800cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ccd871f7efa7dd3f4cf4539249fc3d5703332ad774d014004f49af062616c1b08425b996496ae6dab6969cee9be280e9fb94e1b40a7915923dddec0e5abd33f
|
7
|
+
data.tar.gz: f1800d2772a5683d0dcacd5d4c1c891cd1e6d3e12eaf9a1834035ac6c310d2ebf8875713730666d7de2dfc40037f3a477d9a0e7cf0f5399d97a63581e3668998
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at john@hawthorn.email. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 John Hawthorn
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# bundler-explain
|
2
|
+
|
3
|
+
This project aims to give better explanations conflicts on bundle install.
|
4
|
+
|
5
|
+
Consider this Gemfile:
|
6
|
+
|
7
|
+
```
|
8
|
+
gem 'rails', '~> 5.0.0'
|
9
|
+
gem 'quiet_assets'
|
10
|
+
```
|
11
|
+
|
12
|
+
Running bundle update we get this error:
|
13
|
+
|
14
|
+
```
|
15
|
+
Bundler could not find compatible versions for gem "rails":
|
16
|
+
In Gemfile:
|
17
|
+
rails (~> 5.0.0)
|
18
|
+
|
19
|
+
Could not find gem 'rails (~> 5.0.0)' in any of the sources.
|
20
|
+
|
21
|
+
Bundler could not find compatible versions for gem "railties":
|
22
|
+
In Gemfile:
|
23
|
+
quiet_assets was resolved to 1.0.1, which depends on
|
24
|
+
railties (~> 3.1)
|
25
|
+
|
26
|
+
rails (~> 5.0.0) was resolved to 5.0.0, which depends on
|
27
|
+
railties (= 5.0.0)
|
28
|
+
```
|
29
|
+
|
30
|
+
bundler has tried every version of `quiet_assets` and `rails`, and found that
|
31
|
+
none are compatible. However it's a little unclear from this.
|
32
|
+
|
33
|
+
Bundler can only report one of the many failed combinations it has tried (here
|
34
|
+
`rails 5.0.0` and `quiet_assets 1.0.1`, neither of which the most recent
|
35
|
+
version).
|
36
|
+
|
37
|
+
bundler-explain aims to show the user why there are no possible solutions:
|
38
|
+
|
39
|
+
```
|
40
|
+
Because quiet_assets 1.0.1 depends on railties ~> 3.1
|
41
|
+
and quiet_assets <= 1.0.0 depends on rails ~> 3.1,
|
42
|
+
quiet_assets <= 1.0.0 OR 1.0.1 requires railties ~> 3.1 or rails ~> 3.1.
|
43
|
+
And because quiet_assets >= 1.0.2 depends on railties < 5.0, >= 3.1,
|
44
|
+
either railties < 5.0, >= 3.1 or rails ~> 3.1.
|
45
|
+
So, because rails >= 5.0.0, <= 5.0.7 depends on railties ~> 5.0.0
|
46
|
+
and root depends on rails ~> 5.0.0,
|
47
|
+
version solving has failed.
|
48
|
+
```
|
49
|
+
|
50
|
+
With more gems, bundler's output will be more verbose but bundler-explain will
|
51
|
+
only describe relevant gems. [See a more complex example](https://gist.github.com/jhawthorn/480dab06ade950161d3bd0db0018538e).
|
52
|
+
|
53
|
+
bundler-explain uses [PubGrub](https://github.com/jhawthorn/pub_grub) to
|
54
|
+
determine the cause of the failure.
|
55
|
+
|
56
|
+
## Installation and Usage
|
57
|
+
|
58
|
+
```
|
59
|
+
$ bundler plugin install bundler-explain
|
60
|
+
```
|
61
|
+
|
62
|
+
This will install the `bundler-explain` plugin and `bundle update` will now use
|
63
|
+
bundler-explain's error messages.
|
64
|
+
|
65
|
+
![](http://i.hawth.ca/s/Ln3zIDao.png)
|
66
|
+
|
67
|
+
## Development
|
68
|
+
|
69
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
70
|
+
|
71
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jhawthorn/bundler-explain. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
80
|
+
|
81
|
+
## Code of Conduct
|
82
|
+
|
83
|
+
Everyone interacting in the Bundler::Explain project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jhawthorn/bundler-explain/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bundler/explain"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "bundler/explain/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bundler-explain"
|
8
|
+
spec.version = Bundler::Explain::VERSION
|
9
|
+
spec.authors = ["John Hawthorn"]
|
10
|
+
spec.email = ["john@hawthorn.email"]
|
11
|
+
|
12
|
+
spec.summary = %q{Explains bundle update conflicts}
|
13
|
+
spec.description = %q{Gives better explanations of conflicts when running bundle update.}
|
14
|
+
spec.homepage = "https://github.com/jhawthorn/bundler-explain"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_dependency "pub_grub", "~> 0.2.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "bundler"
|
2
|
+
require "bundler/explain/version"
|
3
|
+
require "bundler/explain/source"
|
4
|
+
|
5
|
+
module Bundler
|
6
|
+
module Explain
|
7
|
+
def self.register
|
8
|
+
Bundler::Plugin.add_hook('before-install-all') do |dependencies|
|
9
|
+
require "bundler/explain/overrides"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'pub_grub'
|
2
|
+
require "bundler/explain/source"
|
3
|
+
|
4
|
+
Bundler::Resolver.prepend(Module.new do
|
5
|
+
def version_conflict_message(e)
|
6
|
+
definition = Bundler.definition
|
7
|
+
requirements = definition.send(:expanded_dependencies)
|
8
|
+
platform = @platforms.first # probably wrong
|
9
|
+
|
10
|
+
source = Bundler::Explain::Source.new(
|
11
|
+
resolver: self,
|
12
|
+
requirements: requirements,
|
13
|
+
platform: platform
|
14
|
+
)
|
15
|
+
|
16
|
+
solver = PubGrub::VersionSolver.new(source: source)
|
17
|
+
|
18
|
+
begin
|
19
|
+
solver.solve
|
20
|
+
rescue PubGrub::SolveFailure => e
|
21
|
+
# Great. PubGrub found the source of the conflict.
|
22
|
+
# Let's report it to the user.
|
23
|
+
return <<MSG
|
24
|
+
Bundler could not find compatible versions of all gems.
|
25
|
+
|
26
|
+
This explanation comes from bundler-explain, please report any issues to
|
27
|
+
https://github.com/jhawthorn/bundler-explain/issues
|
28
|
+
|
29
|
+
#{e.explanation}
|
30
|
+
MSG
|
31
|
+
rescue
|
32
|
+
# If PubGrub fails for any reason, ignore it
|
33
|
+
end
|
34
|
+
|
35
|
+
# We weren't able to find the cause using PubGrub.
|
36
|
+
# Fall back to bundler's built-in error reporting.
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end)
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'pub_grub'
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
module Explain
|
5
|
+
class Source
|
6
|
+
def initialize(requirements:, platform:, resolver:)
|
7
|
+
@definition = Bundler.definition(true)
|
8
|
+
@requirements = requirements
|
9
|
+
@resolver = resolver
|
10
|
+
|
11
|
+
@specs_by_name = Hash.new do |h, name|
|
12
|
+
@resolver.search_for(Bundler::DepProxy.new(Gem::Dependency.new(name), platform)).reverse
|
13
|
+
end
|
14
|
+
|
15
|
+
@sorted_specs_by_name = Hash.new do |h, name|
|
16
|
+
h[name] = @specs_by_name[name].sort_by(&:version)
|
17
|
+
end
|
18
|
+
|
19
|
+
@package_by_name = Hash.new do |h, name|
|
20
|
+
h[name] =
|
21
|
+
PubGrub::Package.new(name) do |package|
|
22
|
+
@specs_by_name[name].each do |spec_group|
|
23
|
+
package.add_version spec_group.version.to_s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
@deps_by_spec = Hash.new do |h, s|
|
29
|
+
h[s] = s.dependencies_for_activated_platforms.map do |dep|
|
30
|
+
[dep.name, dep.requirement]
|
31
|
+
end.to_h
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def incompatibilities_for(version)
|
36
|
+
return enum_for(__method__, version) unless block_given?
|
37
|
+
|
38
|
+
package = version.package
|
39
|
+
|
40
|
+
if version == PubGrub::Package.root_version
|
41
|
+
source_constraint = PubGrub::VersionConstraint.exact(version)
|
42
|
+
source_term = PubGrub::Term.new(source_constraint, true)
|
43
|
+
|
44
|
+
@requirements.each do |dependency|
|
45
|
+
target_constraint = constraint_for_dep(dependency.name, dependency.dep.requirement)
|
46
|
+
target_term = PubGrub::Term.new(target_constraint, false)
|
47
|
+
|
48
|
+
yield PubGrub::Incompatibility.new([source_term, target_term], cause: :dependency)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
specs = @specs_by_name[version.package.name]
|
52
|
+
spec = specs.detect { |s| s.version.to_s == version.name }
|
53
|
+
raise "can't find spec" unless spec
|
54
|
+
|
55
|
+
@deps_by_spec[spec].each do |dep_name, dep_requirement|
|
56
|
+
# Default case
|
57
|
+
target_constraint = constraint_for_dep(dep_name, dep_requirement)
|
58
|
+
source_constraint = range_constraint(spec) do |near_spec|
|
59
|
+
@deps_by_spec[near_spec][dep_name] == dep_requirement
|
60
|
+
end
|
61
|
+
yield dependency_incompatiblity(source_constraint, target_constraint)
|
62
|
+
|
63
|
+
# Special case: exact dependencies (like rails 5.0.7 requires)
|
64
|
+
# We want to add an extra loosened (semver-like) dependency in
|
65
|
+
# addition to the exact dependency above.
|
66
|
+
if dep_requirement.exact?
|
67
|
+
dep_version = dep_requirement.requirements[0][1]
|
68
|
+
if dep_version == spec.version
|
69
|
+
derived_requirements(dep_version).each do |new_requirement|
|
70
|
+
next unless new_requirement === dep_version
|
71
|
+
|
72
|
+
target_constraint = constraint_for_dep(dep_name, new_requirement)
|
73
|
+
source_constraint = range_constraint(spec) do |near_spec|
|
74
|
+
near_dep = @deps_by_spec[near_spec][dep_name]
|
75
|
+
|
76
|
+
near_dep && near_dep.exact? && new_requirement === near_dep.requirements[0][1]
|
77
|
+
end
|
78
|
+
|
79
|
+
yield dependency_incompatiblity(source_constraint, target_constraint)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def derived_requirements(original_version)
|
90
|
+
return enum_for(__method__, original_version) unless block_given?
|
91
|
+
|
92
|
+
v = original_version
|
93
|
+
s = original_version.segments
|
94
|
+
|
95
|
+
return [] unless s.length == 3
|
96
|
+
|
97
|
+
yield Gem::Requirement.new(">= #{s[0]}.#{s[1]}.a", "< #{v.release}")
|
98
|
+
yield Gem::Requirement.new(["~> #{s[0]}.#{s[1]}.0"])
|
99
|
+
yield Gem::Requirement.new(["~> #{s[0]}.#{s[1]}.0.a"])
|
100
|
+
yield Gem::Requirement.new(["~> #{s[0]}.0.a"])
|
101
|
+
end
|
102
|
+
|
103
|
+
def dependency_incompatiblity(source_constraint, target_constraint)
|
104
|
+
source_term = PubGrub::Term.new(source_constraint, true)
|
105
|
+
target_term = PubGrub::Term.new(target_constraint, false)
|
106
|
+
PubGrub::Incompatibility.new([source_term, target_term], cause: :dependency)
|
107
|
+
end
|
108
|
+
|
109
|
+
def range_constraint(spec, &block)
|
110
|
+
sorted_specs = @sorted_specs_by_name[spec.name]
|
111
|
+
package = @package_by_name[spec.name]
|
112
|
+
|
113
|
+
low, high = range_matching(sorted_specs, sorted_specs.index(spec), &block)
|
114
|
+
constraint_between_specs(package, low && sorted_specs[low], high && sorted_specs[high])
|
115
|
+
end
|
116
|
+
|
117
|
+
def constraint_between_specs(package, low_spec, high_spec)
|
118
|
+
low_version = low_spec && low_spec.version
|
119
|
+
high_version = high_spec && high_spec.version
|
120
|
+
|
121
|
+
if !low_spec && !high_spec
|
122
|
+
PubGrub::VersionConstraint.any(package)
|
123
|
+
elsif low_spec == high_spec
|
124
|
+
PubGrub::VersionConstraint.exact(package.version(low_version.to_s))
|
125
|
+
else
|
126
|
+
low = ">= #{low_version}" if low_spec
|
127
|
+
high = "<= #{high_version}" if high_spec
|
128
|
+
PubGrub::VersionConstraint.new(package, [low, high].compact)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def range_matching(sorted_list, index)
|
133
|
+
low = high = index
|
134
|
+
|
135
|
+
raise "range_matching started at non-matching index" unless yield(sorted_list[index])
|
136
|
+
|
137
|
+
loop do
|
138
|
+
high += 1
|
139
|
+
if high >= sorted_list.length
|
140
|
+
high = nil
|
141
|
+
break
|
142
|
+
end
|
143
|
+
break unless yield(sorted_list[high])
|
144
|
+
end
|
145
|
+
|
146
|
+
loop do
|
147
|
+
low -= 1
|
148
|
+
if low < 0
|
149
|
+
low = nil
|
150
|
+
break
|
151
|
+
end
|
152
|
+
break unless yield(sorted_list[low])
|
153
|
+
end
|
154
|
+
|
155
|
+
[low && low + 1, high && high - 1]
|
156
|
+
end
|
157
|
+
|
158
|
+
def constraint_for_dep(name, requirement)
|
159
|
+
package = @package_by_name[name]
|
160
|
+
|
161
|
+
# This is awful. We should try to reuse Gem::Requirement
|
162
|
+
requirement = requirement.to_s.split(", ")
|
163
|
+
|
164
|
+
PubGrub::VersionConstraint.new(package, requirement)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
data/plugins.rb
ADDED
data/test.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
$LOAD_PATH.unshift "./lib"
|
2
|
+
require 'bundler/explain'
|
3
|
+
require 'pub_grub'
|
4
|
+
|
5
|
+
ENV['DEBUG'] = 'true'
|
6
|
+
|
7
|
+
Bundler.ui = Bundler::UI::Shell.new
|
8
|
+
PubGrub.logger.level = Logger::DEBUG
|
9
|
+
|
10
|
+
definition = Bundler.definition(true)
|
11
|
+
requirements = definition.send(:expanded_dependencies)
|
12
|
+
platform = definition.platforms.first # probably wrong
|
13
|
+
resolver = definition.instance_eval do
|
14
|
+
@remote = true
|
15
|
+
sources.remote!
|
16
|
+
|
17
|
+
platforms = Set.new(platforms)
|
18
|
+
base = Bundler::SpecSet.new([])
|
19
|
+
Bundler::Resolver.new(index, source_requirements, base, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Because we don't #start, we need to hack some things in
|
23
|
+
resolver.instance_eval do
|
24
|
+
@prerelease_specified = {}
|
25
|
+
requirements.each {|dep| @prerelease_specified[dep.name] ||= dep.prerelease? }
|
26
|
+
|
27
|
+
verify_gemfile_dependencies_are_found!(requirements)
|
28
|
+
end
|
29
|
+
|
30
|
+
source = Bundler::Explain::Source.new(
|
31
|
+
requirements: requirements,
|
32
|
+
resolver: resolver,
|
33
|
+
platform: platform
|
34
|
+
)
|
35
|
+
|
36
|
+
solver = PubGrub::VersionSolver.new(source: source)
|
37
|
+
result = solver.solve
|
38
|
+
|
39
|
+
pp result
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-explain
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Hawthorn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pub_grub
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description: Gives better explanations of conflicts when running bundle update.
|
70
|
+
email:
|
71
|
+
- john@hawthorn.email
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- CODE_OF_CONDUCT.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- bundler-explain.gemspec
|
86
|
+
- lib/bundler/explain.rb
|
87
|
+
- lib/bundler/explain/overrides.rb
|
88
|
+
- lib/bundler/explain/source.rb
|
89
|
+
- lib/bundler/explain/version.rb
|
90
|
+
- plugins.rb
|
91
|
+
- test.rb
|
92
|
+
homepage: https://github.com/jhawthorn/bundler-explain
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.7.3
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Explains bundle update conflicts
|
116
|
+
test_files: []
|