bundler 2.1.4 → 2.2.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2017 -1430
- data/README.md +7 -9
- data/bundler.gemspec +5 -6
- data/exe/bundle +3 -0
- data/lib/bundler/build_metadata.rb +3 -11
- data/lib/bundler/cli/add.rb +1 -1
- data/lib/bundler/cli/binstubs.rb +6 -2
- data/lib/bundler/cli/cache.rb +3 -8
- data/lib/bundler/cli/check.rb +4 -2
- data/lib/bundler/cli/clean.rb +1 -1
- data/lib/bundler/cli/common.rb +29 -2
- data/lib/bundler/cli/console.rb +1 -1
- data/lib/bundler/cli/doctor.rb +16 -5
- data/lib/bundler/cli/exec.rb +5 -10
- data/lib/bundler/cli/fund.rb +36 -0
- data/lib/bundler/cli/gem.rb +209 -28
- data/lib/bundler/cli/info.rb +28 -5
- data/lib/bundler/cli/init.rb +2 -2
- data/lib/bundler/cli/inject.rb +1 -1
- data/lib/bundler/cli/install.rb +22 -34
- data/lib/bundler/cli/issue.rb +5 -4
- data/lib/bundler/cli/list.rb +19 -11
- data/lib/bundler/cli/lock.rb +5 -1
- data/lib/bundler/cli/open.rb +1 -2
- data/lib/bundler/cli/outdated.rb +95 -75
- data/lib/bundler/cli/plugin.rb +10 -0
- data/lib/bundler/cli/pristine.rb +5 -0
- data/lib/bundler/cli/remove.rb +1 -2
- data/lib/bundler/cli/show.rb +1 -1
- data/lib/bundler/cli/update.rb +14 -7
- data/lib/bundler/cli.rb +89 -66
- data/lib/bundler/compact_index_client/cache.rb +6 -14
- data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
- data/lib/bundler/compact_index_client/updater.rb +13 -22
- data/lib/bundler/compact_index_client.rb +3 -3
- data/lib/bundler/current_ruby.rb +5 -4
- data/lib/bundler/definition.rb +193 -363
- data/lib/bundler/dep_proxy.rb +16 -9
- data/lib/bundler/dependency.rb +3 -10
- data/lib/bundler/digest.rb +71 -0
- data/lib/bundler/dsl.rb +71 -47
- data/lib/bundler/endpoint_specification.rb +1 -1
- data/lib/bundler/env.rb +1 -1
- data/lib/bundler/environment_preserver.rb +29 -2
- data/lib/bundler/errors.rb +20 -3
- data/lib/bundler/feature_flag.rb +0 -8
- data/lib/bundler/fetcher/base.rb +1 -1
- data/lib/bundler/fetcher/compact_index.rb +2 -2
- data/lib/bundler/fetcher/downloader.rb +10 -7
- data/lib/bundler/fetcher/index.rb +3 -5
- data/lib/bundler/fetcher.rb +7 -5
- data/lib/bundler/friendly_errors.rb +25 -43
- data/lib/bundler/gem_helper.rb +53 -31
- data/lib/bundler/gem_helpers.rb +36 -25
- data/lib/bundler/gem_version_promoter.rb +4 -4
- data/lib/bundler/graph.rb +1 -1
- data/lib/bundler/index.rb +9 -9
- data/lib/bundler/injector.rb +23 -5
- data/lib/bundler/inline.rb +3 -2
- data/lib/bundler/installer/gem_installer.rb +6 -19
- data/lib/bundler/installer/parallel_installer.rb +46 -25
- data/lib/bundler/installer/standalone.rb +30 -10
- data/lib/bundler/installer.rb +36 -56
- data/lib/bundler/lazy_specification.rb +62 -26
- data/lib/bundler/lockfile_generator.rb +1 -1
- data/lib/bundler/lockfile_parser.rb +8 -34
- data/lib/bundler/man/.document +1 -0
- data/{man → lib/bundler/man}/bundle-add.1 +1 -1
- data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
- data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
- data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
- data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-check.1 +1 -1
- data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
- data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-config.1 +40 -41
- data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +50 -53
- data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
- data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
- data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
- data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
- data/{man → lib/bundler/man}/bundle-info.1 +1 -1
- data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-init.1 +1 -1
- data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
- data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-install.1 +30 -3
- data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +25 -3
- data/{man → lib/bundler/man}/bundle-list.1 +7 -7
- data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
- data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
- data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-open.1 +1 -1
- data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
- data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
- data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
- data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
- data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-show.1 +1 -1
- data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle-update.1 +4 -4
- data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +3 -3
- data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
- data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
- data/{man → lib/bundler/man}/bundle.1 +1 -1
- data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
- data/{man → lib/bundler/man}/gemfile.5 +30 -4
- data/{man → lib/bundler/man}/gemfile.5.ronn +12 -4
- data/{man → lib/bundler/man}/index.txt +0 -0
- data/lib/bundler/mirror.rb +2 -2
- data/lib/bundler/plugin/api/source.rb +23 -1
- data/lib/bundler/plugin/dsl.rb +1 -1
- data/lib/bundler/plugin/index.rb +13 -1
- data/lib/bundler/plugin/installer/rubygems.rb +1 -1
- data/lib/bundler/plugin/installer.rb +11 -11
- data/lib/bundler/plugin/source_list.rb +5 -1
- data/lib/bundler/plugin.rb +56 -11
- data/lib/bundler/psyched_yaml.rb +0 -15
- data/lib/bundler/remote_specification.rb +5 -2
- data/lib/bundler/resolver/spec_group.rb +56 -53
- data/lib/bundler/resolver.rb +94 -128
- data/lib/bundler/retry.rb +2 -2
- data/lib/bundler/ruby_version.rb +1 -1
- data/lib/bundler/rubygems_ext.rb +96 -16
- data/lib/bundler/rubygems_gem_installer.rb +69 -8
- data/lib/bundler/rubygems_integration.rb +57 -72
- data/lib/bundler/runtime.rb +22 -25
- data/lib/bundler/settings.rb +142 -64
- data/lib/bundler/setup.rb +2 -2
- data/lib/bundler/shared_helpers.rb +5 -13
- data/lib/bundler/similarity_detector.rb +1 -1
- data/lib/bundler/source/git/git_proxy.rb +88 -84
- data/lib/bundler/source/git.rb +43 -23
- data/lib/bundler/source/metadata.rb +0 -4
- data/lib/bundler/source/path/installer.rb +10 -10
- data/lib/bundler/source/path.rb +10 -4
- data/lib/bundler/source/rubygems/remote.rb +1 -1
- data/lib/bundler/source/rubygems.rb +126 -116
- data/lib/bundler/source/rubygems_aggregate.rb +68 -0
- data/lib/bundler/source.rb +22 -1
- data/lib/bundler/source_list.rb +101 -63
- data/lib/bundler/source_map.rb +58 -0
- data/lib/bundler/spec_set.rb +26 -41
- data/lib/bundler/stub_specification.rb +25 -7
- data/lib/bundler/templates/Executable.bundler +6 -6
- data/lib/bundler/templates/Gemfile +1 -1
- data/lib/bundler/templates/gems.rb +1 -1
- data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
- data/lib/bundler/templates/newgem/Gemfile.tt +12 -1
- data/lib/bundler/templates/newgem/README.md.tt +6 -5
- data/lib/bundler/templates/newgem/Rakefile.tt +23 -5
- data/lib/bundler/templates/newgem/bin/console.tt +1 -0
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
- data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
- data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
- data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
- data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
- data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
- data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
- data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
- data/lib/bundler/ui/shell.rb +5 -5
- data/lib/bundler/uri_credentials_filter.rb +3 -1
- data/lib/bundler/vendor/.document +1 -0
- data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
- data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
- data/lib/bundler/vendor/molinillo/LICENSE +9 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +36 -4
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +3 -3
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
- data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
- data/lib/bundler/vendor/thor/LICENSE.md +20 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
- data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
- data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
- data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
- data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
- data/lib/bundler/vendored_persistent.rb +0 -7
- data/lib/bundler/vendored_tmpdir.rb +4 -0
- data/lib/bundler/vendored_tsort.rb +4 -0
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/worker.rb +20 -5
- data/lib/bundler/yaml_serializer.rb +1 -1
- data/lib/bundler.rb +52 -37
- metadata +90 -89
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
- data/man/bundle-add.1.txt +0 -58
- data/man/bundle-binstubs.1.txt +0 -48
- data/man/bundle-cache.1.txt +0 -78
- data/man/bundle-check.1.txt +0 -33
- data/man/bundle-clean.1.txt +0 -26
- data/man/bundle-config.1.txt +0 -528
- data/man/bundle-doctor.1.txt +0 -44
- data/man/bundle-exec.1.txt +0 -178
- data/man/bundle-gem.1.txt +0 -91
- data/man/bundle-info.1.txt +0 -21
- data/man/bundle-init.1.txt +0 -34
- data/man/bundle-inject.1.txt +0 -32
- data/man/bundle-install.1.txt +0 -401
- data/man/bundle-list.1.txt +0 -43
- data/man/bundle-lock.1.txt +0 -93
- data/man/bundle-open.1.txt +0 -29
- data/man/bundle-outdated.1.txt +0 -131
- data/man/bundle-platform.1.txt +0 -57
- data/man/bundle-pristine.1.txt +0 -44
- data/man/bundle-remove.1.txt +0 -34
- data/man/bundle-show.1.txt +0 -27
- data/man/bundle-update.1.txt +0 -390
- data/man/bundle-viz.1.txt +0 -39
- data/man/bundle.1.txt +0 -116
- data/man/gemfile.5.txt +0 -649
data/lib/bundler/definition.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "lockfile_parser"
|
4
|
-
require "set"
|
5
4
|
|
6
5
|
module Bundler
|
7
6
|
class Definition
|
@@ -57,10 +56,8 @@ module Bundler
|
|
57
56
|
@unlocking_bundler = false
|
58
57
|
@unlocking = unlock
|
59
58
|
else
|
60
|
-
unlock = unlock.dup
|
61
59
|
@unlocking_bundler = unlock.delete(:bundler)
|
62
|
-
unlock.
|
63
|
-
@unlocking = !unlock.empty?
|
60
|
+
@unlocking = unlock.any? {|_k, v| !Array(v).empty? }
|
64
61
|
end
|
65
62
|
|
66
63
|
@dependencies = dependencies
|
@@ -76,7 +73,7 @@ module Bundler
|
|
76
73
|
@lockfile_contents = String.new
|
77
74
|
@locked_bundler_version = nil
|
78
75
|
@locked_ruby_version = nil
|
79
|
-
@
|
76
|
+
@new_platform = nil
|
80
77
|
|
81
78
|
if lockfile && File.exist?(lockfile)
|
82
79
|
@lockfile_contents = Bundler.read_file(lockfile)
|
@@ -106,27 +103,43 @@ module Bundler
|
|
106
103
|
@locked_platforms = []
|
107
104
|
end
|
108
105
|
|
109
|
-
@
|
106
|
+
locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
|
107
|
+
@multisource_allowed = locked_gem_sources.size == 1 && locked_gem_sources.first.multiple_remotes? && Bundler.frozen_bundle?
|
108
|
+
|
109
|
+
if @multisource_allowed
|
110
|
+
unless sources.aggregate_global_source?
|
111
|
+
msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure."
|
112
|
+
|
113
|
+
Bundler::SharedHelpers.major_deprecation 2, msg
|
114
|
+
end
|
115
|
+
|
116
|
+
@sources.merged_gem_lockfile_sections!(locked_gem_sources.first)
|
117
|
+
end
|
118
|
+
|
110
119
|
@unlock[:sources] ||= []
|
111
120
|
@unlock[:ruby] ||= if @ruby_version && locked_ruby_version_object
|
112
121
|
@ruby_version.diff(locked_ruby_version_object)
|
113
122
|
end
|
114
123
|
@unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
|
115
124
|
|
116
|
-
add_current_platform unless Bundler.frozen_bundle?
|
125
|
+
add_current_platform unless current_ruby_platform_locked? || Bundler.frozen_bundle?
|
117
126
|
|
118
127
|
converge_path_sources_to_gemspec_sources
|
119
128
|
@path_changes = converge_paths
|
120
129
|
@source_changes = converge_sources
|
121
130
|
|
122
|
-
|
123
|
-
|
124
|
-
|
131
|
+
if @unlock[:conservative]
|
132
|
+
@unlock[:gems] ||= @dependencies.map(&:name)
|
133
|
+
else
|
134
|
+
eager_unlock = expand_dependencies(@unlock[:gems] || [], true)
|
135
|
+
@unlock[:gems] = @locked_specs.for(eager_unlock, false, false).map(&:name)
|
125
136
|
end
|
126
137
|
|
127
138
|
@dependency_changes = converge_dependencies
|
128
139
|
@local_changes = converge_locals
|
129
140
|
|
141
|
+
@locked_specs_incomplete_for_platform = !@locked_specs.for(requested_dependencies & expand_dependencies(locked_dependencies), true, true)
|
142
|
+
|
130
143
|
@requires = compute_requires
|
131
144
|
end
|
132
145
|
|
@@ -145,17 +158,21 @@ module Bundler
|
|
145
158
|
end
|
146
159
|
end
|
147
160
|
|
161
|
+
def resolve_only_locally!
|
162
|
+
@remote = false
|
163
|
+
sources.local_only!
|
164
|
+
resolve
|
165
|
+
end
|
166
|
+
|
148
167
|
def resolve_with_cache!
|
149
|
-
raise "Specs already loaded" if @specs
|
150
168
|
sources.cached!
|
151
|
-
|
169
|
+
resolve
|
152
170
|
end
|
153
171
|
|
154
172
|
def resolve_remotely!
|
155
|
-
raise "Specs already loaded" if @specs
|
156
173
|
@remote = true
|
157
174
|
sources.remote!
|
158
|
-
|
175
|
+
resolve
|
159
176
|
end
|
160
177
|
|
161
178
|
# For given dependency list returns a SpecSet with Gemspec of all the required
|
@@ -165,25 +182,7 @@ module Bundler
|
|
165
182
|
#
|
166
183
|
# @return [Bundler::SpecSet]
|
167
184
|
def specs
|
168
|
-
@specs ||=
|
169
|
-
begin
|
170
|
-
specs = resolve.materialize(requested_dependencies)
|
171
|
-
rescue GemNotFound => e # Handle yanked gem
|
172
|
-
gem_name, gem_version = extract_gem_info(e)
|
173
|
-
locked_gem = @locked_specs[gem_name].last
|
174
|
-
raise if locked_gem.nil? || locked_gem.version.to_s != gem_version || !@remote
|
175
|
-
raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
|
176
|
-
"be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
|
177
|
-
"that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
|
178
|
-
"to a version other than #{locked_gem} that hasn't been removed in order to install."
|
179
|
-
end
|
180
|
-
unless specs["bundler"].any?
|
181
|
-
bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
|
182
|
-
specs["bundler"] = bundler
|
183
|
-
end
|
184
|
-
|
185
|
-
specs
|
186
|
-
end
|
185
|
+
@specs ||= materialize(requested_dependencies)
|
187
186
|
end
|
188
187
|
|
189
188
|
def new_specs
|
@@ -194,14 +193,8 @@ module Bundler
|
|
194
193
|
@locked_specs - specs
|
195
194
|
end
|
196
195
|
|
197
|
-
def new_platform?
|
198
|
-
@new_platform
|
199
|
-
end
|
200
|
-
|
201
196
|
def missing_specs
|
202
|
-
|
203
|
-
resolve.materialize(requested_dependencies, missing)
|
204
|
-
missing
|
197
|
+
resolve.materialize(requested_dependencies).missing_specs
|
205
198
|
end
|
206
199
|
|
207
200
|
def missing_specs?
|
@@ -210,7 +203,6 @@ module Bundler
|
|
210
203
|
Bundler.ui.debug "The definition is missing #{missing.map(&:full_name)}"
|
211
204
|
true
|
212
205
|
rescue BundlerError => e
|
213
|
-
@index = nil
|
214
206
|
@resolve = nil
|
215
207
|
@specs = nil
|
216
208
|
@gem_version_promoter = nil
|
@@ -220,21 +212,35 @@ module Bundler
|
|
220
212
|
end
|
221
213
|
|
222
214
|
def requested_specs
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
215
|
+
specs_for(requested_groups)
|
216
|
+
end
|
217
|
+
|
218
|
+
def requested_dependencies
|
219
|
+
dependencies_for(requested_groups)
|
228
220
|
end
|
229
221
|
|
230
222
|
def current_dependencies
|
231
|
-
dependencies.select
|
223
|
+
dependencies.select do |d|
|
224
|
+
d.should_include? && !d.gem_platforms(@platforms).empty?
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def locked_dependencies
|
229
|
+
@locked_deps.values
|
232
230
|
end
|
233
231
|
|
234
232
|
def specs_for(groups)
|
235
|
-
|
236
|
-
deps
|
237
|
-
|
233
|
+
return specs if groups.empty?
|
234
|
+
deps = dependencies_for(groups)
|
235
|
+
materialize(deps)
|
236
|
+
end
|
237
|
+
|
238
|
+
def dependencies_for(groups)
|
239
|
+
groups.map!(&:to_sym)
|
240
|
+
deps = current_dependencies.reject do |d|
|
241
|
+
(d.groups & groups).empty?
|
242
|
+
end
|
243
|
+
expand_dependencies(deps)
|
238
244
|
end
|
239
245
|
|
240
246
|
# Resolve all the dependencies specified in Gemfile. It ensures that
|
@@ -245,76 +251,20 @@ module Bundler
|
|
245
251
|
def resolve
|
246
252
|
@resolve ||= begin
|
247
253
|
last_resolve = converge_locked_specs
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
end
|
260
|
-
|
261
|
-
# filter out gems that _can_ be installed on multiple platforms, but don't need
|
262
|
-
# to be
|
263
|
-
resolve.for(expand_dependencies(dependencies, true), [], false, false, false)
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
def index
|
268
|
-
@index ||= Index.build do |idx|
|
269
|
-
dependency_names = @dependencies.map(&:name)
|
270
|
-
|
271
|
-
sources.all_sources.each do |source|
|
272
|
-
source.dependency_names = dependency_names - pinned_spec_names(source)
|
273
|
-
idx.add_source source.specs
|
274
|
-
dependency_names.concat(source.unmet_deps).uniq!
|
275
|
-
end
|
276
|
-
|
277
|
-
double_check_for_index(idx, dependency_names)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
# Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
|
282
|
-
# sources A and B. At this point, the API request will have found all the versions of Bar in source A,
|
283
|
-
# but will not have found any versions of Bar from source B, which is a problem if the requested version
|
284
|
-
# of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
|
285
|
-
# each spec we found, we add all possible versions from all sources to the index.
|
286
|
-
def double_check_for_index(idx, dependency_names)
|
287
|
-
pinned_names = pinned_spec_names
|
288
|
-
loop do
|
289
|
-
idxcount = idx.size
|
290
|
-
|
291
|
-
names = :names # do this so we only have to traverse to get dependency_names from the index once
|
292
|
-
unmet_dependency_names = lambda do
|
293
|
-
return names unless names == :names
|
294
|
-
new_names = sources.all_sources.map(&:dependency_names_to_double_check)
|
295
|
-
return names = nil if new_names.compact!
|
296
|
-
names = new_names.flatten(1).concat(dependency_names)
|
297
|
-
names.uniq!
|
298
|
-
names -= pinned_names
|
299
|
-
names
|
300
|
-
end
|
301
|
-
|
302
|
-
sources.all_sources.each do |source|
|
303
|
-
source.double_check_for(unmet_dependency_names)
|
254
|
+
if Bundler.frozen_bundle?
|
255
|
+
Bundler.ui.debug "Frozen, using resolution from the lockfile"
|
256
|
+
last_resolve
|
257
|
+
elsif !unlocking? && nothing_changed?
|
258
|
+
Bundler.ui.debug("Found no changes, using resolution from the lockfile")
|
259
|
+
last_resolve
|
260
|
+
else
|
261
|
+
# Run a resolve against the locally available gems
|
262
|
+
Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
|
263
|
+
expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote)
|
264
|
+
Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
|
304
265
|
end
|
305
|
-
|
306
|
-
break if idxcount == idx.size
|
307
266
|
end
|
308
267
|
end
|
309
|
-
private :double_check_for_index
|
310
|
-
|
311
|
-
def has_rubygems_remotes?
|
312
|
-
sources.rubygems_sources.any? {|s| s.remotes.any? }
|
313
|
-
end
|
314
|
-
|
315
|
-
def has_local_dependencies?
|
316
|
-
!sources.path_sources.empty? || !sources.git_sources.empty?
|
317
|
-
end
|
318
268
|
|
319
269
|
def spec_git_paths
|
320
270
|
sources.git_sources.map {|s| File.realpath(s.path) if File.exist?(s.path) }.compact
|
@@ -396,12 +346,10 @@ module Bundler
|
|
396
346
|
"updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
|
397
347
|
|
398
348
|
unless explicit_flag
|
399
|
-
suggested_command = if Bundler.settings.locations("frozen")[:global]
|
349
|
+
suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
|
400
350
|
"bundle config unset frozen"
|
401
351
|
elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
|
402
352
|
"bundle config unset deployment"
|
403
|
-
else
|
404
|
-
"bundle install --no-deployment"
|
405
353
|
end
|
406
354
|
msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
|
407
355
|
"freeze \nby running `#{suggested_command}`."
|
@@ -416,44 +364,26 @@ module Bundler
|
|
416
364
|
added.concat new_platforms.map {|p| "* platform: #{p}" }
|
417
365
|
deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }
|
418
366
|
|
419
|
-
|
420
|
-
|
421
|
-
new_sources = gemfile_sources - @locked_sources
|
422
|
-
deleted_sources = @locked_sources - gemfile_sources
|
423
|
-
|
424
|
-
new_deps = @dependencies - @locked_deps.values
|
425
|
-
deleted_deps = @locked_deps.values - @dependencies
|
426
|
-
|
427
|
-
# Check if it is possible that the source is only changed thing
|
428
|
-
if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
|
429
|
-
new_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
|
430
|
-
deleted_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
|
431
|
-
end
|
432
|
-
|
433
|
-
if @locked_sources != gemfile_sources
|
434
|
-
if new_sources.any?
|
435
|
-
added.concat new_sources.map {|source| "* source: #{source}" }
|
436
|
-
end
|
437
|
-
|
438
|
-
if deleted_sources.any?
|
439
|
-
deleted.concat deleted_sources.map {|source| "* source: #{source}" }
|
440
|
-
end
|
441
|
-
end
|
367
|
+
new_deps = @dependencies - locked_dependencies
|
368
|
+
deleted_deps = locked_dependencies - @dependencies
|
442
369
|
|
443
370
|
added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
|
444
|
-
if deleted_deps.any?
|
445
|
-
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" }
|
446
|
-
end
|
371
|
+
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
|
447
372
|
|
448
373
|
both_sources = Hash.new {|h, k| h[k] = [] }
|
449
374
|
@dependencies.each {|d| both_sources[d.name][0] = d }
|
450
|
-
|
375
|
+
locked_dependencies.each {|d| both_sources[d.name][1] = d }
|
376
|
+
|
377
|
+
both_sources.each do |name, (dep, lock_dep)|
|
378
|
+
next if dep.nil? || lock_dep.nil?
|
379
|
+
|
380
|
+
gemfile_source = dep.source || sources.default_source
|
381
|
+
lock_source = lock_dep.source || sources.default_source
|
382
|
+
next if lock_source.include?(gemfile_source)
|
451
383
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
lockfile_source_name = lock_source || "no specified source"
|
456
|
-
changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
|
384
|
+
gemfile_source_name = dep.source ? gemfile_source.identifier : "no specified source"
|
385
|
+
lockfile_source_name = lock_dep.source ? lock_source.identifier : "no specified source"
|
386
|
+
changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
|
457
387
|
end
|
458
388
|
|
459
389
|
reason = change_reason
|
@@ -497,15 +427,11 @@ module Bundler
|
|
497
427
|
end
|
498
428
|
|
499
429
|
def validate_platforms!
|
500
|
-
return if
|
501
|
-
Bundler.rubygems.platforms.any? do |local_platform|
|
502
|
-
MatchPlatform.platforms_match?(bundle_platform, local_platform)
|
503
|
-
end
|
504
|
-
end
|
430
|
+
return if current_platform_locked?
|
505
431
|
|
506
432
|
raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
|
507
|
-
"but your local
|
508
|
-
"
|
433
|
+
"but your local platform is #{Bundler.local_platform}. " \
|
434
|
+
"Add the current platform to the lockfile with `bundle lock --add-platform #{Bundler.local_platform}` and try again."
|
509
435
|
end
|
510
436
|
|
511
437
|
def add_platform(platform)
|
@@ -518,16 +444,10 @@ module Bundler
|
|
518
444
|
raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}"
|
519
445
|
end
|
520
446
|
|
521
|
-
def
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
def find_resolved_spec(current_spec)
|
526
|
-
specs.find_by_name_and_platform(current_spec.name, current_spec.platform)
|
527
|
-
end
|
528
|
-
|
529
|
-
def find_indexed_specs(current_spec)
|
530
|
-
index[current_spec.name].select {|spec| spec.match_platform(current_spec.platform) }.sort_by(&:version)
|
447
|
+
def most_specific_locked_platform
|
448
|
+
@platforms.min_by do |bundle_platform|
|
449
|
+
platform_specificity_match(bundle_platform, local_platform)
|
450
|
+
end
|
531
451
|
end
|
532
452
|
|
533
453
|
attr_reader :sources
|
@@ -541,14 +461,51 @@ module Bundler
|
|
541
461
|
@unlocking
|
542
462
|
end
|
543
463
|
|
544
|
-
|
464
|
+
private
|
465
|
+
|
466
|
+
def materialize(dependencies)
|
467
|
+
specs = resolve.materialize(dependencies)
|
468
|
+
missing_specs = specs.missing_specs
|
469
|
+
|
470
|
+
if missing_specs.any?
|
471
|
+
missing_specs.each do |s|
|
472
|
+
locked_gem = @locked_specs[s.name].last
|
473
|
+
next if locked_gem.nil? || locked_gem.version != s.version || !@remote
|
474
|
+
raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
|
475
|
+
"no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
|
476
|
+
"You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
|
477
|
+
"removed in order to install."
|
478
|
+
end
|
545
479
|
|
546
|
-
|
547
|
-
current_platform = Bundler.local_platform
|
548
|
-
[].tap do |platforms|
|
549
|
-
platforms << current_platform if Bundler.feature_flag.specific_platform?
|
550
|
-
platforms << generic(current_platform)
|
480
|
+
raise GemNotFound, "Could not find #{missing_specs.map(&:full_name).join(", ")} in any of the sources"
|
551
481
|
end
|
482
|
+
|
483
|
+
unless specs["bundler"].any?
|
484
|
+
bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
|
485
|
+
specs["bundler"] = bundler
|
486
|
+
end
|
487
|
+
|
488
|
+
specs
|
489
|
+
end
|
490
|
+
|
491
|
+
def precompute_source_requirements_for_indirect_dependencies?
|
492
|
+
@remote && sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && !sources.aggregate_global_source?
|
493
|
+
end
|
494
|
+
|
495
|
+
def current_ruby_platform_locked?
|
496
|
+
return false unless generic_local_platform == Gem::Platform::RUBY
|
497
|
+
|
498
|
+
current_platform_locked?
|
499
|
+
end
|
500
|
+
|
501
|
+
def current_platform_locked?
|
502
|
+
@platforms.any? do |bundle_platform|
|
503
|
+
MatchPlatform.platforms_match?(bundle_platform, Bundler.local_platform)
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
def add_current_platform
|
508
|
+
add_platform(local_platform)
|
552
509
|
end
|
553
510
|
|
554
511
|
def change_reason
|
@@ -587,9 +544,9 @@ module Bundler
|
|
587
544
|
|
588
545
|
def dependencies_for_source_changed?(source, locked_source = source)
|
589
546
|
deps_for_source = @dependencies.select {|s| s.source == source }
|
590
|
-
locked_deps_for_source =
|
547
|
+
locked_deps_for_source = locked_dependencies.select {|dep| dep.source == locked_source }
|
591
548
|
|
592
|
-
|
549
|
+
deps_for_source.uniq.sort != locked_deps_for_source.sort
|
593
550
|
end
|
594
551
|
|
595
552
|
def specs_for_source_changed?(source)
|
@@ -648,36 +605,11 @@ module Bundler
|
|
648
605
|
end
|
649
606
|
end
|
650
607
|
|
651
|
-
def converge_rubygems_sources
|
652
|
-
return false if Bundler.feature_flag.disable_multisource?
|
653
|
-
|
654
|
-
changes = false
|
655
|
-
|
656
|
-
# Get the RubyGems sources from the Gemfile.lock
|
657
|
-
locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
|
658
|
-
# Get the RubyGems remotes from the Gemfile
|
659
|
-
actual_remotes = sources.rubygems_remotes
|
660
|
-
|
661
|
-
# If there is a RubyGems source in both
|
662
|
-
if !locked_gem_sources.empty? && !actual_remotes.empty?
|
663
|
-
locked_gem_sources.each do |locked_gem|
|
664
|
-
# Merge the remotes from the Gemfile into the Gemfile.lock
|
665
|
-
changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
|
666
|
-
end
|
667
|
-
end
|
668
|
-
|
669
|
-
changes
|
670
|
-
end
|
671
|
-
|
672
608
|
def converge_sources
|
673
|
-
changes = false
|
674
|
-
|
675
|
-
changes |= converge_rubygems_sources
|
676
|
-
|
677
609
|
# Replace the sources from the Gemfile with the sources from the Gemfile.lock,
|
678
610
|
# if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
|
679
611
|
# source in the Gemfile.lock, use the one from the Gemfile.
|
680
|
-
changes
|
612
|
+
changes = sources.replace_sources!(@locked_sources)
|
681
613
|
|
682
614
|
sources.all_sources.each do |source|
|
683
615
|
# If the source is unlockable and the current command allows an unlock of
|
@@ -695,28 +627,14 @@ module Bundler
|
|
695
627
|
end
|
696
628
|
|
697
629
|
def converge_dependencies
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
# after locked_source and sources don't match, we still use locked_source.
|
703
|
-
if frozen && !locked_source.nil? &&
|
704
|
-
locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist?
|
705
|
-
dep.source = locked_source.source
|
706
|
-
elsif dep.source
|
630
|
+
changes = false
|
631
|
+
|
632
|
+
@dependencies.each do |dep|
|
633
|
+
if dep.source
|
707
634
|
dep.source = sources.get(dep.source)
|
708
635
|
end
|
709
|
-
if dep.source.is_a?(Source::Gemspec)
|
710
|
-
dep.platforms.concat(@platforms.map {|p| Dependency::REVERSE_PLATFORM_MAP[p] }.flatten(1)).uniq!
|
711
|
-
end
|
712
|
-
end
|
713
636
|
|
714
|
-
|
715
|
-
# We want to know if all match, but don't want to check all entries
|
716
|
-
# This means we need to return false if any dependency doesn't match
|
717
|
-
# the lock or doesn't exist in the lock.
|
718
|
-
@dependencies.each do |dependency|
|
719
|
-
unless locked_dep = @locked_deps[dependency.name]
|
637
|
+
unless locked_dep = @locked_deps[dep.name]
|
720
638
|
changes = true
|
721
639
|
next
|
722
640
|
end
|
@@ -727,11 +645,11 @@ module Bundler
|
|
727
645
|
# directive, the lockfile dependencies and resolved dependencies end up
|
728
646
|
# with a mismatch on #type. Work around that by setting the type on the
|
729
647
|
# dep from the lockfile.
|
730
|
-
locked_dep.instance_variable_set(:@type,
|
648
|
+
locked_dep.instance_variable_set(:@type, dep.type)
|
731
649
|
|
732
650
|
# We already know the name matches from the hash lookup
|
733
651
|
# so we only need to check the requirement now
|
734
|
-
changes ||=
|
652
|
+
changes ||= dep.requirement != locked_dep.requirement
|
735
653
|
end
|
736
654
|
|
737
655
|
changes
|
@@ -741,47 +659,37 @@ module Bundler
|
|
741
659
|
# commonly happen if the Gemfile has changed since the lockfile was last
|
742
660
|
# generated
|
743
661
|
def converge_locked_specs
|
744
|
-
|
745
|
-
|
746
|
-
# Build a list of dependencies that are the same in the Gemfile
|
747
|
-
# and Gemfile.lock. If the Gemfile modified a dependency, but
|
748
|
-
# the gem in the Gemfile.lock still satisfies it, this is fine
|
749
|
-
# too.
|
750
|
-
@dependencies.each do |dep|
|
751
|
-
locked_dep = @locked_deps[dep.name]
|
662
|
+
resolve = converge_specs(@locked_specs)
|
752
663
|
|
753
|
-
|
754
|
-
locked_dep = nil unless locked_dep == dep
|
664
|
+
diff = nil
|
755
665
|
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
@locked_specs.each do |s|
|
760
|
-
@unlock[:gems] << s.name if s.source == dep.source
|
761
|
-
end
|
666
|
+
# Now, we unlock any sources that do not have anymore gems pinned to it
|
667
|
+
sources.all_sources.each do |source|
|
668
|
+
next unless source.respond_to?(:unlock!)
|
762
669
|
|
763
|
-
|
764
|
-
|
670
|
+
unless resolve.any? {|s| s.source == source }
|
671
|
+
diff ||= @locked_specs.to_a - resolve.to_a
|
672
|
+
source.unlock! if diff.any? {|s| s.source == source }
|
765
673
|
end
|
766
674
|
end
|
767
675
|
|
768
|
-
|
676
|
+
resolve
|
677
|
+
end
|
769
678
|
|
679
|
+
def converge_specs(specs)
|
680
|
+
deps = []
|
770
681
|
converged = []
|
771
|
-
|
682
|
+
specs.each do |s|
|
772
683
|
# Replace the locked dependency's source with the equivalent source from the Gemfile
|
773
684
|
dep = @dependencies.find {|d| s.satisfies?(d) }
|
774
|
-
s.source = (dep && dep.source) || sources.get(s.source)
|
775
685
|
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
next if @unlock[:sources].include?(s.source.name)
|
686
|
+
if dep && (!dep.source || s.source.include?(dep.source))
|
687
|
+
deps << dep
|
688
|
+
end
|
780
689
|
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
next if unlock_source_unlocks_spec && @unlock[:sources].include?(s.name)
|
690
|
+
s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source unless Bundler.frozen_bundle?
|
691
|
+
|
692
|
+
next if @unlock[:sources].include?(s.source.name)
|
785
693
|
|
786
694
|
# If the spec is from a path source and it doesn't exist anymore
|
787
695
|
# then we unlock it.
|
@@ -793,8 +701,8 @@ module Bundler
|
|
793
701
|
rescue PathError, GitError
|
794
702
|
# if we won't need the source (according to the lockfile),
|
795
703
|
# don't error if the path/git source isn't available
|
796
|
-
next if
|
797
|
-
for(requested_dependencies,
|
704
|
+
next if specs.
|
705
|
+
for(requested_dependencies, false, true).
|
798
706
|
none? {|locked_spec| locked_spec.source == s.source }
|
799
707
|
|
800
708
|
raise
|
@@ -806,61 +714,23 @@ module Bundler
|
|
806
714
|
# commonly happens if the version changed in the gemspec
|
807
715
|
next unless new_spec
|
808
716
|
|
809
|
-
new_runtime_deps = new_spec.dependencies.select {|d| d.type != :development }
|
810
|
-
old_runtime_deps = s.dependencies.select {|d| d.type != :development }
|
811
|
-
# If the dependencies of the path source have changed and locked spec can't satisfy new dependencies, unlock it
|
812
|
-
next unless new_runtime_deps.sort == old_runtime_deps.sort || new_runtime_deps.all? {|d| satisfies_locked_spec?(d) }
|
813
|
-
|
814
717
|
s.dependencies.replace(new_spec.dependencies)
|
815
718
|
end
|
816
719
|
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
@locked_specs_incomplete_for_platform = !resolve.for(expand_dependencies(deps), @unlock[:gems], true, true)
|
822
|
-
resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems], false, false, false)
|
823
|
-
diff = nil
|
824
|
-
|
825
|
-
# Now, we unlock any sources that do not have anymore gems pinned to it
|
826
|
-
sources.all_sources.each do |source|
|
827
|
-
next unless source.respond_to?(:unlock!)
|
828
|
-
|
829
|
-
unless resolve.any? {|s| s.source == source }
|
830
|
-
diff ||= @locked_specs.to_a - resolve.to_a
|
831
|
-
source.unlock! if diff.any? {|s| s.source == source }
|
720
|
+
if dep.nil? && requested_dependencies.find {|d| s.name == d.name }
|
721
|
+
@unlock[:gems] << s.name
|
722
|
+
else
|
723
|
+
converged << s
|
832
724
|
end
|
833
725
|
end
|
834
726
|
|
835
|
-
resolve
|
836
|
-
|
837
|
-
|
838
|
-
def in_locked_deps?(dep, locked_dep)
|
839
|
-
# Because the lockfile can't link a dep to a specific remote, we need to
|
840
|
-
# treat sources as equivalent anytime the locked dep has all the remotes
|
841
|
-
# that the Gemfile dep does.
|
842
|
-
locked_dep && locked_dep.source && dep.source && locked_dep.source.include?(dep.source)
|
843
|
-
end
|
844
|
-
|
845
|
-
def satisfies_locked_spec?(dep)
|
846
|
-
@locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
|
847
|
-
end
|
848
|
-
|
849
|
-
# This list of dependencies is only used in #resolve, so it's OK to add
|
850
|
-
# the metadata dependencies here
|
851
|
-
def expanded_dependencies
|
852
|
-
@expanded_dependencies ||= begin
|
853
|
-
expand_dependencies(dependencies + metadata_dependencies, @remote)
|
854
|
-
end
|
727
|
+
resolve = SpecSet.new(converged)
|
728
|
+
SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) })
|
855
729
|
end
|
856
730
|
|
857
731
|
def metadata_dependencies
|
858
732
|
@metadata_dependencies ||= begin
|
859
|
-
ruby_versions =
|
860
|
-
if ruby_versions.empty? || !@ruby_version.exact?
|
861
|
-
concat_ruby_version_requirements(RubyVersion.system)
|
862
|
-
concat_ruby_version_requirements(locked_ruby_version_object) unless @unlock[:ruby]
|
863
|
-
end
|
733
|
+
ruby_versions = ruby_version_requirements(@ruby_version)
|
864
734
|
[
|
865
735
|
Dependency.new("Ruby\0", ruby_versions),
|
866
736
|
Dependency.new("RubyGems\0", Gem::VERSION),
|
@@ -868,83 +738,56 @@ module Bundler
|
|
868
738
|
end
|
869
739
|
end
|
870
740
|
|
871
|
-
def
|
872
|
-
return
|
741
|
+
def ruby_version_requirements(ruby_version)
|
742
|
+
return [] unless ruby_version
|
873
743
|
if ruby_version.patchlevel
|
874
|
-
|
744
|
+
[ruby_version.to_gem_version_with_patchlevel]
|
875
745
|
else
|
876
|
-
|
746
|
+
ruby_version.versions.map do |version|
|
877
747
|
requirement = Gem::Requirement.new(version)
|
878
748
|
if requirement.exact?
|
879
749
|
"~> #{version}.0"
|
880
750
|
else
|
881
751
|
requirement
|
882
752
|
end
|
883
|
-
end
|
753
|
+
end
|
884
754
|
end
|
885
755
|
end
|
886
756
|
|
887
757
|
def expand_dependencies(dependencies, remote = false)
|
888
|
-
sorted_platforms = Resolver.sort_platforms(@platforms)
|
889
758
|
deps = []
|
890
759
|
dependencies.each do |dep|
|
891
760
|
dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
|
892
|
-
next
|
893
|
-
|
894
|
-
|
895
|
-
mapped_platforms = dep.expanded_platforms
|
896
|
-
Bundler.ui.warn \
|
897
|
-
"The dependency #{dep} will be unused by any of the platforms Bundler is installing for. " \
|
898
|
-
"Bundler is installing for #{@platforms.join ", "} but the dependency " \
|
899
|
-
"is only for #{mapped_platforms.join ", "}. " \
|
900
|
-
"To add those platforms to the bundle, " \
|
901
|
-
"run `bundle lock --add-platform #{mapped_platforms.join " "}`."
|
902
|
-
end
|
903
|
-
platforms.each do |p|
|
904
|
-
deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
|
905
|
-
end
|
761
|
+
next unless remote || dep.current_platform?
|
762
|
+
target_platforms = dep.gem_platforms(remote ? @platforms : [generic_local_platform])
|
763
|
+
deps += expand_dependency_with_platforms(dep, target_platforms)
|
906
764
|
end
|
907
765
|
deps
|
908
766
|
end
|
909
767
|
|
910
|
-
def
|
911
|
-
|
912
|
-
|
913
|
-
|
768
|
+
def expand_dependency_with_platforms(dep, platforms)
|
769
|
+
platforms.map do |p|
|
770
|
+
DepProxy.get_proxy(dep, p)
|
771
|
+
end
|
914
772
|
end
|
915
773
|
|
916
774
|
def source_requirements
|
917
|
-
# Load all specs from remote sources
|
918
|
-
index
|
919
|
-
|
920
775
|
# Record the specs available in each gem's source, so that those
|
921
776
|
# specs will be available later when the resolver knows where to
|
922
777
|
# look for that gemspec (or its dependencies)
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
next unless source = dep.source || default
|
928
|
-
source_requirements[dep.name] = source
|
778
|
+
source_requirements = if precompute_source_requirements_for_indirect_dependencies?
|
779
|
+
{ :default => sources.default_source }.merge(source_map.all_requirements)
|
780
|
+
else
|
781
|
+
{ :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
|
929
782
|
end
|
930
783
|
metadata_dependencies.each do |dep|
|
931
784
|
source_requirements[dep.name] = sources.metadata_source
|
932
785
|
end
|
786
|
+
source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
|
933
787
|
source_requirements["bundler"] = sources.metadata_source # needs to come last to override
|
934
788
|
source_requirements
|
935
789
|
end
|
936
790
|
|
937
|
-
def pinned_spec_names(skip = nil)
|
938
|
-
pinned_names = []
|
939
|
-
default = Bundler.feature_flag.disable_multisource? && sources.default_source
|
940
|
-
@dependencies.each do |dep|
|
941
|
-
next unless dep_source = dep.source || default
|
942
|
-
next if dep_source == skip
|
943
|
-
pinned_names << dep.name
|
944
|
-
end
|
945
|
-
pinned_names
|
946
|
-
end
|
947
|
-
|
948
791
|
def requested_groups
|
949
792
|
groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
|
950
793
|
end
|
@@ -962,12 +805,6 @@ module Bundler
|
|
962
805
|
current == proposed
|
963
806
|
end
|
964
807
|
|
965
|
-
def extract_gem_info(error)
|
966
|
-
# This method will extract the error message like "Could not find foo-1.2.3 in any of the sources"
|
967
|
-
# to an array. The first element will be the gem name (e.g. foo), the second will be the version number.
|
968
|
-
error.message.scan(/Could not find (\w+)-(\d+(?:\.\d+)+)/).flatten
|
969
|
-
end
|
970
|
-
|
971
808
|
def compute_requires
|
972
809
|
dependencies.reduce({}) do |requires, dep|
|
973
810
|
next requires unless dep.should_include?
|
@@ -980,23 +817,16 @@ module Bundler
|
|
980
817
|
end
|
981
818
|
|
982
819
|
def additional_base_requirements_for_resolve
|
983
|
-
return [] unless @locked_gems &&
|
984
|
-
|
985
|
-
@locked_gems.specs.reduce({}) do |requirements, locked_spec|
|
820
|
+
return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
|
821
|
+
converge_specs(@locked_gems.specs).map do |locked_spec|
|
986
822
|
name = locked_spec.name
|
987
|
-
dependency = dependencies_by_name[name]
|
988
|
-
next requirements if @locked_gems.dependencies[name] != dependency
|
989
|
-
next requirements if dependency && dependency.source.is_a?(Source::Path)
|
990
823
|
dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
|
991
|
-
|
992
|
-
|
993
|
-
end.values
|
824
|
+
DepProxy.get_proxy(dep, locked_spec.platform)
|
825
|
+
end
|
994
826
|
end
|
995
827
|
|
996
|
-
def
|
997
|
-
|
998
|
-
|
999
|
-
Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
|
828
|
+
def source_map
|
829
|
+
@source_map ||= SourceMap.new(sources, dependencies)
|
1000
830
|
end
|
1001
831
|
end
|
1002
832
|
end
|