bundler 2.2.29 → 2.5.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1129 -4
- data/README.md +4 -8
- data/bundler.gemspec +11 -11
- data/exe/bundle +5 -26
- data/exe/bundler +1 -1
- data/lib/bundler/.document +1 -0
- data/lib/bundler/build_metadata.rb +4 -4
- data/lib/bundler/capistrano.rb +1 -1
- data/lib/bundler/checksum.rb +254 -0
- data/lib/bundler/ci_detector.rb +75 -0
- data/lib/bundler/cli/add.rb +4 -4
- data/lib/bundler/cli/binstubs.rb +10 -6
- data/lib/bundler/cli/cache.rb +1 -1
- data/lib/bundler/cli/check.rb +3 -3
- data/lib/bundler/cli/common.rb +13 -3
- data/lib/bundler/cli/config.rb +18 -8
- data/lib/bundler/cli/console.rb +5 -4
- data/lib/bundler/cli/doctor.rb +12 -5
- data/lib/bundler/cli/exec.rb +1 -1
- data/lib/bundler/cli/fund.rb +1 -1
- data/lib/bundler/cli/gem.rb +141 -48
- data/lib/bundler/cli/info.rb +27 -17
- data/lib/bundler/cli/init.rb +6 -2
- data/lib/bundler/cli/install.rb +22 -39
- data/lib/bundler/cli/issue.rb +5 -4
- data/lib/bundler/cli/lock.rb +36 -29
- data/lib/bundler/cli/open.rb +9 -9
- data/lib/bundler/cli/outdated.rb +19 -12
- data/lib/bundler/cli/platform.rb +8 -6
- data/lib/bundler/cli/plugin.rb +9 -15
- data/lib/bundler/cli/pristine.rb +38 -30
- data/lib/bundler/cli/show.rb +3 -3
- data/lib/bundler/cli/update.rb +12 -7
- data/lib/bundler/cli/viz.rb +1 -1
- data/lib/bundler/cli.rb +266 -285
- data/lib/bundler/compact_index_client/cache.rb +53 -67
- data/lib/bundler/compact_index_client/cache_file.rb +153 -0
- data/lib/bundler/compact_index_client/gem_parser.rb +7 -3
- data/lib/bundler/compact_index_client/parser.rb +84 -0
- data/lib/bundler/compact_index_client/updater.rb +83 -76
- data/lib/bundler/compact_index_client.rb +59 -87
- data/lib/bundler/constants.rb +9 -2
- data/lib/bundler/current_ruby.rb +12 -16
- data/lib/bundler/definition.rb +509 -319
- data/lib/bundler/dependency.rb +33 -71
- data/lib/bundler/digest.rb +71 -0
- data/lib/bundler/dsl.rb +88 -69
- data/lib/bundler/endpoint_specification.rb +32 -15
- data/lib/bundler/env.rb +5 -7
- data/lib/bundler/environment_preserver.rb +8 -22
- data/lib/bundler/errors.rb +101 -13
- data/lib/bundler/feature_flag.rb +0 -2
- data/lib/bundler/fetcher/base.rb +11 -11
- data/lib/bundler/fetcher/compact_index.rb +32 -52
- data/lib/bundler/fetcher/dependency.rb +3 -7
- data/lib/bundler/fetcher/downloader.rb +17 -16
- data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
- data/lib/bundler/fetcher/index.rb +2 -29
- data/lib/bundler/fetcher.rb +87 -79
- data/lib/bundler/force_platform.rb +18 -0
- data/lib/bundler/friendly_errors.rb +29 -40
- data/lib/bundler/gem_helper.rb +11 -23
- data/lib/bundler/gem_helpers.rb +30 -6
- data/lib/bundler/gem_version_promoter.rb +68 -109
- data/lib/bundler/graph.rb +9 -9
- data/lib/bundler/index.rb +71 -79
- data/lib/bundler/injector.rb +23 -11
- data/lib/bundler/inline.rb +11 -23
- data/lib/bundler/installer/gem_installer.rb +18 -11
- data/lib/bundler/installer/parallel_installer.rb +17 -65
- data/lib/bundler/installer/standalone.rb +56 -15
- data/lib/bundler/installer.rb +35 -61
- data/lib/bundler/lazy_specification.rb +92 -61
- data/lib/bundler/lockfile_generator.rb +12 -3
- data/lib/bundler/lockfile_parser.rb +137 -70
- data/lib/bundler/man/bundle-add.1 +19 -26
- data/lib/bundler/man/bundle-add.1.ronn +16 -4
- data/lib/bundler/man/bundle-binstubs.1 +4 -16
- data/lib/bundler/man/bundle-cache.1 +9 -24
- data/lib/bundler/man/bundle-cache.1.ronn +9 -2
- data/lib/bundler/man/bundle-check.1 +5 -12
- data/lib/bundler/man/bundle-check.1.ronn +3 -0
- data/lib/bundler/man/bundle-clean.1 +4 -11
- data/lib/bundler/man/bundle-clean.1.ronn +1 -1
- data/lib/bundler/man/bundle-config.1 +47 -224
- data/lib/bundler/man/bundle-config.1.ronn +40 -28
- data/lib/bundler/man/bundle-console.1 +35 -0
- data/lib/bundler/man/bundle-console.1.ronn +44 -0
- data/lib/bundler/man/bundle-doctor.1 +4 -18
- data/lib/bundler/man/bundle-exec.1 +16 -77
- data/lib/bundler/man/bundle-exec.1.ronn +8 -9
- data/lib/bundler/man/bundle-gem.1 +45 -72
- data/lib/bundler/man/bundle-gem.1.ronn +32 -5
- data/lib/bundler/man/bundle-help.1 +9 -0
- data/lib/bundler/man/bundle-help.1.ronn +12 -0
- data/lib/bundler/man/bundle-info.1 +5 -11
- data/lib/bundler/man/bundle-info.1.ronn +3 -3
- data/lib/bundler/man/bundle-init.1 +6 -11
- data/lib/bundler/man/bundle-init.1.ronn +2 -0
- data/lib/bundler/man/bundle-inject.1 +8 -18
- data/lib/bundler/man/bundle-inject.1.ronn +3 -1
- data/lib/bundler/man/bundle-install.1 +32 -155
- data/lib/bundler/man/bundle-install.1.ronn +11 -33
- data/lib/bundler/man/bundle-list.1 +4 -19
- data/lib/bundler/man/bundle-lock.1 +5 -29
- data/lib/bundler/man/bundle-open.1 +18 -18
- data/lib/bundler/man/bundle-open.1.ronn +9 -1
- data/lib/bundler/man/bundle-outdated.1 +17 -72
- data/lib/bundler/man/bundle-outdated.1.ronn +13 -18
- data/lib/bundler/man/bundle-platform.1 +16 -28
- data/lib/bundler/man/bundle-platform.1.ronn +14 -7
- data/lib/bundler/man/bundle-plugin.1 +58 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
- data/lib/bundler/man/bundle-pristine.1 +5 -16
- data/lib/bundler/man/bundle-remove.1 +4 -14
- data/lib/bundler/man/bundle-show.1 +3 -10
- data/lib/bundler/man/bundle-update.1 +19 -138
- data/lib/bundler/man/bundle-update.1.ronn +2 -1
- data/lib/bundler/man/bundle-version.1 +22 -0
- data/lib/bundler/man/bundle-version.1.ronn +24 -0
- data/lib/bundler/man/bundle-viz.1 +6 -15
- data/lib/bundler/man/bundle-viz.1.ronn +2 -0
- data/lib/bundler/man/bundle.1 +17 -51
- data/lib/bundler/man/bundle.1.ronn +12 -7
- data/lib/bundler/man/gemfile.5 +130 -346
- data/lib/bundler/man/gemfile.5.ronn +121 -86
- data/lib/bundler/man/index.txt +4 -0
- data/lib/bundler/match_metadata.rb +17 -0
- data/lib/bundler/match_platform.rb +1 -2
- data/lib/bundler/match_remote_metadata.rb +29 -0
- data/lib/bundler/mirror.rb +8 -10
- data/lib/bundler/plugin/api/source.rb +9 -13
- data/lib/bundler/plugin/index.rb +13 -5
- data/lib/bundler/plugin/installer/git.rb +0 -4
- data/lib/bundler/plugin/installer/path.rb +18 -0
- data/lib/bundler/plugin/installer/rubygems.rb +0 -8
- data/lib/bundler/plugin/installer.rb +42 -19
- data/lib/bundler/plugin/source_list.rb +4 -4
- data/lib/bundler/plugin.rb +16 -7
- data/lib/bundler/process_lock.rb +1 -1
- data/lib/bundler/remote_specification.rb +11 -5
- data/lib/bundler/resolver/base.rb +111 -0
- data/lib/bundler/resolver/candidate.rb +82 -0
- data/lib/bundler/resolver/incompatibility.rb +15 -0
- data/lib/bundler/resolver/package.rb +81 -0
- data/lib/bundler/resolver/root.rb +25 -0
- data/lib/bundler/resolver/spec_group.rb +53 -66
- data/lib/bundler/resolver.rb +419 -307
- data/lib/bundler/retry.rb +1 -1
- data/lib/bundler/ruby_dsl.rb +42 -7
- data/lib/bundler/ruby_version.rb +16 -22
- data/lib/bundler/rubygems_ext.rb +250 -64
- data/lib/bundler/rubygems_gem_installer.rb +90 -64
- data/lib/bundler/rubygems_integration.rb +81 -190
- data/lib/bundler/runtime.rb +8 -13
- data/lib/bundler/safe_marshal.rb +31 -0
- data/lib/bundler/self_manager.rb +206 -0
- data/lib/bundler/settings.rb +139 -57
- data/lib/bundler/setup.rb +13 -1
- data/lib/bundler/shared_helpers.rb +67 -36
- data/lib/bundler/source/git/git_proxy.rb +285 -82
- data/lib/bundler/source/git.rb +81 -41
- data/lib/bundler/source/metadata.rb +17 -16
- data/lib/bundler/source/path/installer.rb +1 -22
- data/lib/bundler/source/path.rb +13 -25
- data/lib/bundler/source/rubygems/remote.rb +1 -1
- data/lib/bundler/source/rubygems.rb +164 -234
- data/lib/bundler/source/rubygems_aggregate.rb +1 -1
- data/lib/bundler/source.rb +7 -6
- data/lib/bundler/source_list.rb +40 -32
- data/lib/bundler/source_map.rb +15 -2
- data/lib/bundler/spec_set.rb +156 -46
- data/lib/bundler/stub_specification.rb +18 -5
- data/lib/bundler/templates/Executable +3 -5
- data/lib/bundler/templates/Executable.bundler +7 -12
- data/lib/bundler/templates/Executable.standalone +4 -4
- data/lib/bundler/templates/Gemfile +0 -2
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
- data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
- data/lib/bundler/templates/newgem/README.md.tt +7 -11
- data/lib/bundler/templates/newgem/Rakefile.tt +28 -4
- data/lib/bundler/templates/newgem/bin/console.tt +0 -4
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +13 -3
- data/lib/bundler/templates/newgem/gitignore.tt +3 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +25 -17
- data/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
- data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
- data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
- data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
- data/lib/bundler/ui/rg_proxy.rb +1 -1
- data/lib/bundler/ui/shell.rb +38 -15
- data/lib/bundler/ui/silent.rb +21 -5
- data/lib/bundler/uri_credentials_filter.rb +2 -2
- data/lib/bundler/uri_normalizer.rb +23 -0
- data/lib/bundler/vendor/.document +1 -0
- data/lib/bundler/vendor/connection_pool/.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 +56 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +92 -78
- data/lib/bundler/vendor/fileutils/.document +1 -0
- data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1340 -410
- data/lib/bundler/vendor/net-http-persistent/.document +1 -0
- data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +57 -57
- data/lib/bundler/vendor/pub_grub/.document +1 -0
- data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
- data/lib/bundler/vendor/thor/.document +1 -0
- data/lib/bundler/vendor/thor/LICENSE.md +20 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +12 -14
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +16 -6
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -17
- data/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
- data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +16 -20
- data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +63 -7
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +48 -154
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -46
- data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +0 -45
- data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/util.rb +9 -8
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +155 -8
- data/lib/bundler/vendor/tsort/.document +1 -0
- data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
- data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
- data/lib/bundler/vendor/uri/.document +1 -0
- data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +316 -207
- data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +33 -13
- data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
- data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +105 -47
- data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
- data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
- data/lib/bundler/vendored_net_http.rb +23 -0
- data/lib/bundler/vendored_persistent.rb +0 -36
- data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
- data/lib/bundler/vendored_timeout.rb +12 -0
- data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
- data/lib/bundler/vendored_uri.rb +18 -1
- data/lib/bundler/version.rb +5 -1
- data/lib/bundler/vlad.rb +1 -1
- data/lib/bundler/worker.rb +7 -9
- data/lib/bundler/yaml_serializer.rb +21 -12
- data/lib/bundler.rb +114 -121
- metadata +87 -41
- data/lib/bundler/dep_proxy.rb +0 -55
- data/lib/bundler/gemdeps.rb +0 -29
- data/lib/bundler/psyched_yaml.rb +0 -22
- data/lib/bundler/templates/gems.rb +0 -8
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
- data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
- data/lib/bundler/version_ranges.rb +0 -122
data/lib/bundler/resolver.rb
CHANGED
@@ -1,183 +1,306 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Bundler
|
4
|
+
#
|
5
|
+
# This class implements the interface needed by PubGrub for resolution. It is
|
6
|
+
# equivalent to the `PubGrub::BasicPackageSource` class provided by PubGrub by
|
7
|
+
# default and used by the most simple PubGrub consumers.
|
8
|
+
#
|
4
9
|
class Resolver
|
5
|
-
require_relative "
|
6
|
-
require_relative "resolver/
|
10
|
+
require_relative "vendored_pub_grub"
|
11
|
+
require_relative "resolver/base"
|
12
|
+
require_relative "resolver/candidate"
|
13
|
+
require_relative "resolver/incompatibility"
|
14
|
+
require_relative "resolver/root"
|
7
15
|
|
8
16
|
include GemHelpers
|
9
17
|
|
10
|
-
|
11
|
-
|
12
|
-
# causing any gem activation errors.
|
13
|
-
#
|
14
|
-
# ==== Parameters
|
15
|
-
# *dependencies<Gem::Dependency>:: The list of dependencies to resolve
|
16
|
-
#
|
17
|
-
# ==== Returns
|
18
|
-
# <GemBundle>,nil:: If the list of dependencies can be resolved, a
|
19
|
-
# collection of gemspecs is returned. Otherwise, nil is returned.
|
20
|
-
def self.resolve(requirements, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
|
21
|
-
base = SpecSet.new(base) unless base.is_a?(SpecSet)
|
22
|
-
resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
|
23
|
-
result = resolver.start(requirements)
|
24
|
-
SpecSet.new(SpecSet.new(result).for(requirements.reject{|dep| dep.name.end_with?("\0") }))
|
25
|
-
end
|
26
|
-
|
27
|
-
def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
|
28
|
-
@source_requirements = source_requirements
|
18
|
+
def initialize(base, gem_version_promoter)
|
19
|
+
@source_requirements = base.source_requirements
|
29
20
|
@base = base
|
30
|
-
@resolver = Molinillo::Resolver.new(self, self)
|
31
|
-
@search_for = {}
|
32
|
-
@base_dg = Molinillo::DependencyGraph.new
|
33
|
-
aggregate_global_source = @source_requirements[:default].is_a?(Source::RubygemsAggregate)
|
34
|
-
@base.each do |ls|
|
35
|
-
dep = Dependency.new(ls.name, ls.version)
|
36
|
-
ls.source = source_for(ls.name) unless aggregate_global_source
|
37
|
-
@base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true)
|
38
|
-
end
|
39
|
-
additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) }
|
40
|
-
@platforms = platforms.reject {|p| p != Gem::Platform::RUBY && (platforms - [p]).any? {|pl| generic(pl) == p } }
|
41
|
-
@resolving_only_for_ruby = platforms == [Gem::Platform::RUBY]
|
42
21
|
@gem_version_promoter = gem_version_promoter
|
43
|
-
@use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major?
|
44
|
-
end
|
45
|
-
|
46
|
-
def start(requirements)
|
47
|
-
@gem_version_promoter.prerelease_specified = @prerelease_specified = {}
|
48
|
-
requirements.each {|dep| @prerelease_specified[dep.name] ||= dep.prerelease? }
|
49
|
-
|
50
|
-
verify_gemfile_dependencies_are_found!(requirements)
|
51
|
-
dg = @resolver.resolve(requirements, @base_dg)
|
52
|
-
dg.
|
53
|
-
map(&:payload).
|
54
|
-
reject {|sg| sg.name.end_with?("\0") }.
|
55
|
-
map(&:to_specs).
|
56
|
-
flatten
|
57
|
-
rescue Molinillo::VersionConflict => e
|
58
|
-
message = version_conflict_message(e)
|
59
|
-
raise VersionConflict.new(e.conflicts.keys.uniq, message)
|
60
|
-
rescue Molinillo::CircularDependencyError => e
|
61
|
-
names = e.dependencies.sort_by(&:name).map {|d| "gem '#{d.name}'" }
|
62
|
-
raise CyclicDependencyError, "Your bundle requires gems that depend" \
|
63
|
-
" on each other, creating an infinite loop. Please remove" \
|
64
|
-
" #{names.count > 1 ? "either " : ""}#{names.join(" or ")}" \
|
65
|
-
" and try again."
|
66
|
-
end
|
67
|
-
|
68
|
-
include Molinillo::UI
|
69
|
-
|
70
|
-
# Conveys debug information to the user.
|
71
|
-
#
|
72
|
-
# @param [Integer] depth the current depth of the resolution process.
|
73
|
-
# @return [void]
|
74
|
-
def debug(depth = 0)
|
75
|
-
return unless debug?
|
76
|
-
debug_info = yield
|
77
|
-
debug_info = debug_info.inspect unless debug_info.is_a?(String)
|
78
|
-
puts debug_info.split("\n").map {|s| depth == 0 ? "BUNDLER: #{s}" : "BUNDLER(#{depth}): #{s}" }
|
79
22
|
end
|
80
23
|
|
81
|
-
def
|
82
|
-
|
83
|
-
@
|
84
|
-
ENV["BUNDLER_DEBUG_RESOLVER"] ||
|
85
|
-
ENV["BUNDLER_DEBUG_RESOLVER_TREE"] ||
|
86
|
-
ENV["DEBUG_RESOLVER"] ||
|
87
|
-
ENV["DEBUG_RESOLVER_TREE"] ||
|
88
|
-
false
|
89
|
-
end
|
24
|
+
def start
|
25
|
+
@requirements = @base.requirements
|
26
|
+
@packages = @base.packages
|
90
27
|
|
91
|
-
|
92
|
-
Bundler.ui.info "Resolving dependencies...", debug?
|
93
|
-
end
|
28
|
+
root, logger = setup_solver
|
94
29
|
|
95
|
-
|
96
|
-
Bundler.ui.info ""
|
97
|
-
end
|
30
|
+
Bundler.ui.info "Resolving dependencies...", true
|
98
31
|
|
99
|
-
|
100
|
-
Bundler.ui.info ".", false unless debug?
|
32
|
+
solve_versions(root: root, logger: logger)
|
101
33
|
end
|
102
34
|
|
103
|
-
|
35
|
+
def setup_solver
|
36
|
+
root = Resolver::Root.new(name_for_explicit_dependency_source)
|
37
|
+
root_version = Resolver::Candidate.new(0)
|
38
|
+
|
39
|
+
@all_specs = Hash.new do |specs, name|
|
40
|
+
source = source_for(name)
|
41
|
+
matches = source.specs.search(name)
|
42
|
+
|
43
|
+
# Don't bother to check for circular deps when no dependency API are
|
44
|
+
# available, since it's too slow to be usable. That edge case won't work
|
45
|
+
# but resolution other than that should work fine and reasonably fast.
|
46
|
+
if source.respond_to?(:dependency_api_available?) && source.dependency_api_available?
|
47
|
+
matches = filter_invalid_self_dependencies(matches, name)
|
48
|
+
end
|
49
|
+
|
50
|
+
specs[name] = matches.sort_by {|s| [s.version, s.platform.to_s] }
|
51
|
+
end
|
52
|
+
|
53
|
+
@all_versions = Hash.new do |candidates, package|
|
54
|
+
candidates[package] = all_versions_for(package)
|
55
|
+
end
|
56
|
+
|
57
|
+
@sorted_versions = Hash.new do |candidates, package|
|
58
|
+
candidates[package] = filtered_versions_for(package).sort
|
59
|
+
end
|
60
|
+
|
61
|
+
@sorted_versions[root] = [root_version]
|
104
62
|
|
105
|
-
|
106
|
-
|
63
|
+
root_dependencies = prepare_dependencies(@requirements, @packages)
|
64
|
+
|
65
|
+
@cached_dependencies = Hash.new do |dependencies, package|
|
66
|
+
dependencies[package] = Hash.new do |versions, version|
|
67
|
+
versions[version] = to_dependency_hash(version.dependencies.reject {|d| d.name == package.name }, @packages)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
@cached_dependencies[root] = { root_version => root_dependencies }
|
72
|
+
|
73
|
+
logger = Bundler::UI::Shell.new
|
74
|
+
logger.level = debug? ? "debug" : "warn"
|
75
|
+
|
76
|
+
[root, logger]
|
107
77
|
end
|
108
78
|
|
109
|
-
def
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
79
|
+
def solve_versions(root:, logger:)
|
80
|
+
solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
|
81
|
+
result = solver.solve
|
82
|
+
resolved_specs = result.map {|package, version| version.to_specs(package) }.flatten
|
83
|
+
resolved_specs |= @base.specs_compatible_with(SpecSet.new(resolved_specs))
|
84
|
+
rescue PubGrub::SolveFailure => e
|
85
|
+
incompatibility = e.incompatibility
|
86
|
+
|
87
|
+
names_to_unlock, names_to_allow_prereleases_for, extended_explanation = find_names_to_relax(incompatibility)
|
88
|
+
|
89
|
+
names_to_relax = names_to_unlock + names_to_allow_prereleases_for
|
90
|
+
|
91
|
+
if names_to_relax.any?
|
92
|
+
if names_to_unlock.any?
|
93
|
+
Bundler.ui.debug "Found conflicts with locked dependencies. Will retry with #{names_to_unlock.join(", ")} unlocked...", true
|
115
94
|
|
116
|
-
|
117
|
-
locked_requirement = vertex.payload.requirement
|
95
|
+
@base.unlock_names(names_to_unlock)
|
118
96
|
end
|
119
97
|
|
120
|
-
if
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
results = pre + results
|
98
|
+
if names_to_allow_prereleases_for.any?
|
99
|
+
Bundler.ui.debug "Found conflicts with dependencies with prereleases. Will retrying considering prereleases for #{names_to_allow_prereleases_for.join(", ")}...", true
|
100
|
+
|
101
|
+
@base.include_prereleases(names_to_allow_prereleases_for)
|
125
102
|
end
|
126
103
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
104
|
+
root, logger = setup_solver
|
105
|
+
|
106
|
+
Bundler.ui.debug "Retrying resolution...", true
|
107
|
+
retry
|
108
|
+
end
|
109
|
+
|
110
|
+
explanation = e.message
|
111
|
+
|
112
|
+
if extended_explanation
|
113
|
+
explanation << "\n\n"
|
114
|
+
explanation << extended_explanation
|
115
|
+
end
|
116
|
+
|
117
|
+
raise SolveFailure.new(explanation)
|
118
|
+
end
|
119
|
+
|
120
|
+
def find_names_to_relax(incompatibility)
|
121
|
+
names_to_unlock = []
|
122
|
+
names_to_allow_prereleases_for = []
|
123
|
+
extended_explanation = nil
|
124
|
+
|
125
|
+
while incompatibility.conflict?
|
126
|
+
cause = incompatibility.cause
|
127
|
+
incompatibility = cause.incompatibility
|
128
|
+
|
129
|
+
incompatibility.terms.each do |term|
|
130
|
+
package = term.package
|
131
|
+
name = package.name
|
132
|
+
|
133
|
+
if base_requirements[name]
|
134
|
+
names_to_unlock << name
|
135
|
+
elsif package.ignores_prereleases? && @all_specs[name].any? {|s| s.version.prerelease? }
|
136
|
+
names_to_allow_prereleases_for << name
|
136
137
|
end
|
137
|
-
nested.reduce([]) do |groups, (version, specs)|
|
138
|
-
next groups if locked_requirement && !locked_requirement.satisfied_by?(version)
|
139
138
|
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
no_versions_incompat = [cause.incompatibility, cause.satisfier].find {|incompat| incompat.cause.is_a?(PubGrub::Incompatibility::NoVersions) }
|
140
|
+
next unless no_versions_incompat
|
141
|
+
|
142
|
+
extended_explanation = no_versions_incompat.extended_explanation
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
[names_to_unlock.uniq, names_to_allow_prereleases_for.uniq, extended_explanation]
|
147
|
+
end
|
148
|
+
|
149
|
+
def parse_dependency(package, dependency)
|
150
|
+
range = if repository_for(package).is_a?(Source::Gemspec)
|
151
|
+
PubGrub::VersionRange.any
|
152
|
+
else
|
153
|
+
requirement_to_range(dependency)
|
154
|
+
end
|
155
|
+
|
156
|
+
PubGrub::VersionConstraint.new(package, range: range)
|
157
|
+
end
|
158
|
+
|
159
|
+
def versions_for(package, range=VersionRange.any)
|
160
|
+
versions = select_sorted_versions(package, range)
|
161
|
+
|
162
|
+
# Conditional avoids (among other things) calling
|
163
|
+
# sort_versions_by_preferred with the root package
|
164
|
+
if versions.size > 1
|
165
|
+
sort_versions_by_preferred(package, versions)
|
166
|
+
else
|
167
|
+
versions
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def no_versions_incompatibility_for(package, unsatisfied_term)
|
172
|
+
cause = PubGrub::Incompatibility::NoVersions.new(unsatisfied_term)
|
173
|
+
name = package.name
|
174
|
+
constraint = unsatisfied_term.constraint
|
175
|
+
constraint_string = constraint.constraint_string
|
176
|
+
requirements = constraint_string.split(" OR ").map {|req| Gem::Requirement.new(req.split(",")) }
|
177
|
+
|
178
|
+
if name == "bundler" && bundler_pinned_to_current_version?
|
179
|
+
custom_explanation = "the current Bundler version (#{Bundler::VERSION}) does not satisfy #{constraint}"
|
180
|
+
extended_explanation = bundler_not_found_message(requirements)
|
181
|
+
else
|
182
|
+
specs_matching_other_platforms = filter_matching_specs(@all_specs[name], requirements)
|
143
183
|
|
144
|
-
|
145
|
-
|
184
|
+
platforms_explanation = specs_matching_other_platforms.any? ? " for any resolution platforms (#{package.platforms.join(", ")})" : ""
|
185
|
+
custom_explanation = "#{constraint} could not be found in #{repository_for(package)}#{platforms_explanation}"
|
186
|
+
|
187
|
+
label = "#{name} (#{constraint_string})"
|
188
|
+
extended_explanation = other_specs_matching_message(specs_matching_other_platforms, label) if specs_matching_other_platforms.any?
|
189
|
+
end
|
146
190
|
|
147
|
-
|
191
|
+
Incompatibility.new([unsatisfied_term], cause: cause, custom_explanation: custom_explanation, extended_explanation: extended_explanation)
|
192
|
+
end
|
193
|
+
|
194
|
+
def debug?
|
195
|
+
ENV["BUNDLER_DEBUG_RESOLVER"] ||
|
196
|
+
ENV["BUNDLER_DEBUG_RESOLVER_TREE"] ||
|
197
|
+
ENV["DEBUG_RESOLVER"] ||
|
198
|
+
ENV["DEBUG_RESOLVER_TREE"] ||
|
199
|
+
false
|
200
|
+
end
|
148
201
|
|
149
|
-
|
150
|
-
|
202
|
+
def incompatibilities_for(package, version)
|
203
|
+
package_deps = @cached_dependencies[package]
|
204
|
+
sorted_versions = @sorted_versions[package]
|
205
|
+
package_deps[version].map do |dep_package, dep_constraint|
|
206
|
+
low = high = sorted_versions.index(version)
|
151
207
|
|
152
|
-
|
208
|
+
# find version low such that all >= low share the same dep
|
209
|
+
while low > 0 && package_deps[sorted_versions[low - 1]][dep_package] == dep_constraint
|
210
|
+
low -= 1
|
211
|
+
end
|
212
|
+
low =
|
213
|
+
if low == 0
|
214
|
+
nil
|
215
|
+
else
|
216
|
+
sorted_versions[low]
|
153
217
|
end
|
154
|
-
|
155
|
-
|
218
|
+
|
219
|
+
# find version high such that all < high share the same dep
|
220
|
+
while high < sorted_versions.length && package_deps[sorted_versions[high]][dep_package] == dep_constraint
|
221
|
+
high += 1
|
156
222
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
223
|
+
high =
|
224
|
+
if high == sorted_versions.length
|
225
|
+
nil
|
226
|
+
else
|
227
|
+
sorted_versions[high]
|
228
|
+
end
|
229
|
+
|
230
|
+
range = PubGrub::VersionRange.new(min: low, max: high, include_min: true)
|
231
|
+
|
232
|
+
self_constraint = PubGrub::VersionConstraint.new(package, range: range)
|
233
|
+
|
234
|
+
dep_term = PubGrub::Term.new(dep_constraint, false)
|
235
|
+
self_term = PubGrub::Term.new(self_constraint, true)
|
236
|
+
|
237
|
+
custom_explanation = if dep_package.meta? && package.root?
|
238
|
+
"current #{dep_package} version is #{dep_constraint.constraint_string}"
|
163
239
|
end
|
240
|
+
|
241
|
+
PubGrub::Incompatibility.new([self_term, dep_term], cause: :dependency, custom_explanation: custom_explanation)
|
164
242
|
end
|
165
243
|
end
|
166
244
|
|
167
|
-
def
|
168
|
-
|
245
|
+
def all_versions_for(package)
|
246
|
+
name = package.name
|
247
|
+
results = (@base[name] + filter_prereleases(@all_specs[name], package)).uniq {|spec| [spec.version.hash, spec.platform] }
|
248
|
+
|
249
|
+
if name == "bundler" && !bundler_pinned_to_current_version?
|
250
|
+
bundler_spec = Gem.loaded_specs["bundler"]
|
251
|
+
results << bundler_spec if bundler_spec
|
252
|
+
end
|
253
|
+
|
254
|
+
locked_requirement = base_requirements[name]
|
255
|
+
results = filter_matching_specs(results, locked_requirement) if locked_requirement
|
256
|
+
|
257
|
+
results.group_by(&:version).reduce([]) do |groups, (version, specs)|
|
258
|
+
platform_specs = package.platform_specs(specs)
|
259
|
+
|
260
|
+
# If package is a top-level dependency,
|
261
|
+
# candidate is only valid if there are matching versions for all resolution platforms.
|
262
|
+
#
|
263
|
+
# If package is not a top-level deependency,
|
264
|
+
# then it's not necessary that it has matching versions for all platforms, since it may have been introduced only as
|
265
|
+
# a dependency for a platform specific variant, so it will only need to have a valid version for that platform.
|
266
|
+
#
|
267
|
+
if package.top_level?
|
268
|
+
next groups if platform_specs.any?(&:empty?)
|
269
|
+
else
|
270
|
+
next groups if platform_specs.all?(&:empty?)
|
271
|
+
end
|
272
|
+
|
273
|
+
ruby_specs = select_best_platform_match(specs, Gem::Platform::RUBY)
|
274
|
+
ruby_group = Resolver::SpecGroup.new(ruby_specs)
|
275
|
+
|
276
|
+
unless ruby_group.empty?
|
277
|
+
platform_specs.each do |specs|
|
278
|
+
ruby_group.merge(Resolver::SpecGroup.new(specs))
|
279
|
+
end
|
280
|
+
|
281
|
+
groups << Resolver::Candidate.new(version, group: ruby_group, priority: -1)
|
282
|
+
next groups if package.force_ruby_platform?
|
283
|
+
end
|
284
|
+
|
285
|
+
platform_group = Resolver::SpecGroup.new(platform_specs.flatten.uniq)
|
286
|
+
next groups if platform_group == ruby_group
|
287
|
+
|
288
|
+
groups << Resolver::Candidate.new(version, group: platform_group, priority: 1)
|
289
|
+
|
290
|
+
groups
|
291
|
+
end
|
169
292
|
end
|
170
293
|
|
171
294
|
def source_for(name)
|
172
295
|
@source_requirements[name] || @source_requirements[:default]
|
173
296
|
end
|
174
297
|
|
175
|
-
def
|
176
|
-
|
298
|
+
def default_bundler_source
|
299
|
+
@source_requirements[:default_bundler]
|
177
300
|
end
|
178
301
|
|
179
|
-
def
|
180
|
-
|
302
|
+
def bundler_pinned_to_current_version?
|
303
|
+
!default_bundler_source.nil?
|
181
304
|
end
|
182
305
|
|
183
306
|
def name_for_explicit_dependency_source
|
@@ -186,204 +309,193 @@ module Bundler
|
|
186
309
|
"Gemfile"
|
187
310
|
end
|
188
311
|
|
189
|
-
def
|
190
|
-
|
191
|
-
|
192
|
-
|
312
|
+
def raise_not_found!(package)
|
313
|
+
name = package.name
|
314
|
+
source = source_for(name)
|
315
|
+
specs = @all_specs[name]
|
316
|
+
matching_part = name
|
317
|
+
requirement_label = SharedHelpers.pretty_dependency(package.dependency)
|
318
|
+
cache_message = begin
|
319
|
+
" or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
|
320
|
+
rescue GemfileNotFound
|
321
|
+
nil
|
322
|
+
end
|
323
|
+
specs_matching_requirement = filter_matching_specs(specs, package.dependency.requirement)
|
324
|
+
|
325
|
+
not_found_message = if specs_matching_requirement.any?
|
326
|
+
specs = specs_matching_requirement
|
327
|
+
matching_part = requirement_label
|
328
|
+
platforms = package.platforms
|
329
|
+
|
330
|
+
if platforms.size == 1
|
331
|
+
"Could not find gem '#{requirement_label}' with platform '#{platforms.first}'"
|
332
|
+
else
|
333
|
+
"Could not find gems matching '#{requirement_label}' valid for all resolution platforms (#{platforms.join(", ")})"
|
334
|
+
end
|
335
|
+
else
|
336
|
+
"Could not find gem '#{requirement_label}'"
|
337
|
+
end
|
338
|
+
|
339
|
+
message = String.new("#{not_found_message} in #{source}#{cache_message}.\n")
|
340
|
+
|
341
|
+
if specs.any?
|
342
|
+
message << "\n#{other_specs_matching_message(specs, matching_part)}"
|
343
|
+
end
|
344
|
+
|
345
|
+
raise GemNotFound, message
|
193
346
|
end
|
194
347
|
|
195
|
-
|
196
|
-
|
348
|
+
private
|
349
|
+
|
350
|
+
def filtered_versions_for(package)
|
351
|
+
@gem_version_promoter.filter_versions(package, @all_versions[package])
|
197
352
|
end
|
198
353
|
|
199
|
-
def
|
200
|
-
|
354
|
+
def raise_all_versions_filtered_out!(package)
|
355
|
+
level = @gem_version_promoter.level
|
356
|
+
name = package.name
|
357
|
+
locked_version = package.locked_version
|
358
|
+
requirement = package.dependency
|
359
|
+
|
360
|
+
raise GemNotFound,
|
361
|
+
"#{name} is locked to #{locked_version}, while Gemfile is requesting #{requirement}. " \
|
362
|
+
"--strict --#{level} was specified, but there are no #{level} level upgrades from #{locked_version} satisfying #{requirement}, so version solving has failed"
|
201
363
|
end
|
202
364
|
|
203
|
-
def
|
204
|
-
|
205
|
-
|
206
|
-
vertex = activated.vertex_named(name)
|
207
|
-
[
|
208
|
-
@base_dg.vertex_named(name) ? 0 : 1,
|
209
|
-
vertex.payload ? 0 : 1,
|
210
|
-
vertex.root? ? 0 : 1,
|
211
|
-
amount_constrained(dependency),
|
212
|
-
conflicts[name] ? 0 : 1,
|
213
|
-
vertex.payload ? 0 : search_for(dependency).count,
|
214
|
-
self.class.platform_sort_key(dependency.__platform),
|
215
|
-
]
|
365
|
+
def filter_matching_specs(specs, requirements)
|
366
|
+
Array(requirements).flat_map do |requirement|
|
367
|
+
specs.select {| spec| requirement_satisfied_by?(requirement, spec) }
|
216
368
|
end
|
217
369
|
end
|
218
370
|
|
219
|
-
def
|
220
|
-
|
221
|
-
|
222
|
-
|
371
|
+
def filter_prereleases(specs, package)
|
372
|
+
return specs unless package.ignores_prereleases? && specs.size > 1
|
373
|
+
|
374
|
+
specs.reject {|s| s.version.prerelease? }
|
223
375
|
end
|
224
376
|
|
225
|
-
|
377
|
+
# Ignore versions that depend on themselves incorrectly
|
378
|
+
def filter_invalid_self_dependencies(specs, name)
|
379
|
+
specs.reject do |s|
|
380
|
+
s.dependencies.any? {|d| d.name == name && !d.requirement.satisfied_by?(s.version) }
|
381
|
+
end
|
382
|
+
end
|
226
383
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
# dependencies w/ 0 or 1 possibilities (ignoring version requirements)
|
231
|
-
# are given very negative values, so they _always_ sort first,
|
232
|
-
# before dependencies that are unconstrained
|
233
|
-
def amount_constrained(dependency)
|
234
|
-
@amount_constrained ||= {}
|
235
|
-
@amount_constrained[dependency.name] ||= begin
|
236
|
-
if (base = @base[dependency.name]) && !base.empty?
|
237
|
-
dependency.requirement.satisfied_by?(base.first.version) ? 0 : 1
|
238
|
-
else
|
239
|
-
all = index_for(dependency).search(dependency.name).size
|
384
|
+
def requirement_satisfied_by?(requirement, spec)
|
385
|
+
requirement.satisfied_by?(spec.version) || spec.source.is_a?(Source::Gemspec)
|
386
|
+
end
|
240
387
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
388
|
+
def sort_versions_by_preferred(package, versions)
|
389
|
+
@gem_version_promoter.sort_versions(package, versions)
|
390
|
+
end
|
391
|
+
|
392
|
+
def repository_for(package)
|
393
|
+
source_for(package.name)
|
394
|
+
end
|
395
|
+
|
396
|
+
def base_requirements
|
397
|
+
@base.base_requirements
|
398
|
+
end
|
399
|
+
|
400
|
+
def prepare_dependencies(requirements, packages)
|
401
|
+
to_dependency_hash(requirements, packages).map do |dep_package, dep_constraint|
|
402
|
+
name = dep_package.name
|
403
|
+
|
404
|
+
next [dep_package, dep_constraint] if name == "bundler"
|
405
|
+
|
406
|
+
dep_range = dep_constraint.range
|
407
|
+
versions = select_sorted_versions(dep_package, dep_range)
|
408
|
+
if versions.empty? && dep_package.ignores_prereleases?
|
409
|
+
@all_versions.delete(dep_package)
|
410
|
+
@sorted_versions.delete(dep_package)
|
411
|
+
dep_package.consider_prereleases!
|
412
|
+
versions = select_sorted_versions(dep_package, dep_range)
|
248
413
|
end
|
249
|
-
|
414
|
+
|
415
|
+
if versions.empty? && select_all_versions(dep_package, dep_range).any?
|
416
|
+
raise_all_versions_filtered_out!(dep_package)
|
417
|
+
end
|
418
|
+
|
419
|
+
next [dep_package, dep_constraint] unless versions.empty?
|
420
|
+
|
421
|
+
next unless dep_package.current_platform?
|
422
|
+
|
423
|
+
raise_not_found!(dep_package)
|
424
|
+
end.compact.to_h
|
250
425
|
end
|
251
426
|
|
252
|
-
def
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
427
|
+
def select_sorted_versions(package, range)
|
428
|
+
range.select_versions(@sorted_versions[package])
|
429
|
+
end
|
430
|
+
|
431
|
+
def select_all_versions(package, range)
|
432
|
+
range.select_versions(@all_versions[package])
|
433
|
+
end
|
434
|
+
|
435
|
+
def other_specs_matching_message(specs, requirement)
|
436
|
+
message = String.new("The source contains the following gems matching '#{requirement}':\n")
|
437
|
+
message << specs.map {|s| " * #{s.full_name}" }.join("\n")
|
438
|
+
message
|
439
|
+
end
|
440
|
+
|
441
|
+
def requirement_to_range(requirement)
|
442
|
+
ranges = requirement.requirements.map do |(op, version)|
|
443
|
+
ver = Resolver::Candidate.new(version, priority: -1)
|
444
|
+
platform_ver = Resolver::Candidate.new(version, priority: 1)
|
445
|
+
|
446
|
+
case op
|
447
|
+
when "~>"
|
448
|
+
name = "~> #{ver}"
|
449
|
+
bump = Resolver::Candidate.new(version.bump.to_s + ".A")
|
450
|
+
PubGrub::VersionRange.new(name: name, min: ver, max: bump, include_min: true)
|
451
|
+
when ">"
|
452
|
+
PubGrub::VersionRange.new(min: platform_ver)
|
453
|
+
when ">="
|
454
|
+
PubGrub::VersionRange.new(min: ver, include_min: true)
|
455
|
+
when "<"
|
456
|
+
PubGrub::VersionRange.new(max: ver)
|
457
|
+
when "<="
|
458
|
+
PubGrub::VersionRange.new(max: platform_ver, include_max: true)
|
459
|
+
when "="
|
460
|
+
PubGrub::VersionRange.new(min: ver, max: platform_ver, include_min: true, include_max: true)
|
461
|
+
when "!="
|
462
|
+
PubGrub::VersionRange.new(min: ver, max: platform_ver, include_min: true, include_max: true).invert
|
266
463
|
else
|
267
|
-
|
268
|
-
specs = source.specs.search(name)
|
269
|
-
versions_with_platforms = specs.map {|s| [s.version, s.platform] }
|
270
|
-
cache_message = begin
|
271
|
-
" or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
|
272
|
-
rescue GemfileNotFound
|
273
|
-
nil
|
274
|
-
end
|
275
|
-
message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source.to_err}#{cache_message}.\n")
|
276
|
-
message << "The source contains the following versions of '#{name}': #{formatted_versions_with_platforms(versions_with_platforms)}" if versions_with_platforms.any?
|
464
|
+
raise "bad version specifier: #{op}"
|
277
465
|
end
|
278
|
-
raise GemNotFound, message
|
279
466
|
end
|
467
|
+
|
468
|
+
ranges.inject(&:intersect)
|
280
469
|
end
|
281
470
|
|
282
|
-
def
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
471
|
+
def to_dependency_hash(dependencies, packages)
|
472
|
+
dependencies.inject({}) do |deps, dep|
|
473
|
+
package = packages[dep.name]
|
474
|
+
|
475
|
+
current_req = deps[package]
|
476
|
+
new_req = parse_dependency(package, dep.requirement)
|
477
|
+
|
478
|
+
deps[package] = if current_req
|
479
|
+
current_req.intersect(new_req)
|
480
|
+
else
|
481
|
+
new_req
|
482
|
+
end
|
483
|
+
|
484
|
+
deps
|
289
485
|
end
|
290
|
-
version_platform_strs.join(", ")
|
291
486
|
end
|
292
487
|
|
293
|
-
def
|
294
|
-
|
295
|
-
conflicts = e.conflicts.dup
|
488
|
+
def bundler_not_found_message(conflict_dependencies)
|
489
|
+
candidate_specs = filter_matching_specs(default_bundler_source.specs.search("bundler"), conflict_dependencies)
|
296
490
|
|
297
|
-
if
|
298
|
-
|
491
|
+
if candidate_specs.any?
|
492
|
+
target_version = candidate_specs.last.version
|
493
|
+
new_command = [File.basename($PROGRAM_NAME), "_#{target_version}_", *ARGV].join(" ")
|
494
|
+
"Your bundle requires a different version of Bundler than the one you're running.\n" \
|
495
|
+
"Install the necessary version with `gem install bundler:#{target_version}` and rerun bundler using `#{new_command}`\n"
|
299
496
|
else
|
300
|
-
|
301
|
-
deps = conflict.requirement_trees.map(&:last).flatten(1)
|
302
|
-
!Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement)))
|
303
|
-
end
|
497
|
+
"Your bundle requires a different version of Bundler than the one you're running, and that version could not be found.\n"
|
304
498
|
end
|
305
|
-
|
306
|
-
e = Molinillo::VersionConflict.new(conflicts, e.specification_provider) unless conflicts.empty?
|
307
|
-
|
308
|
-
solver_name = "Bundler"
|
309
|
-
possibility_type = "gem"
|
310
|
-
e.message_with_trees(
|
311
|
-
:solver_name => solver_name,
|
312
|
-
:possibility_type => possibility_type,
|
313
|
-
:reduce_trees => lambda do |trees|
|
314
|
-
# called first, because we want to reduce the amount of work required to find maximal empty sets
|
315
|
-
trees = trees.uniq {|t| t.flatten.map {|dep| [dep.name, dep.requirement] } }
|
316
|
-
|
317
|
-
# bail out if tree size is too big for Array#combination to make any sense
|
318
|
-
return trees if trees.size > 15
|
319
|
-
maximal = 1.upto(trees.size).map do |size|
|
320
|
-
trees.map(&:last).flatten(1).combination(size).to_a
|
321
|
-
end.flatten(1).select do |deps|
|
322
|
-
Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement)))
|
323
|
-
end.min_by(&:size)
|
324
|
-
|
325
|
-
trees.reject! {|t| !maximal.include?(t.last) } if maximal
|
326
|
-
|
327
|
-
trees.sort_by {|t| t.reverse.map(&:name) }
|
328
|
-
end,
|
329
|
-
:printable_requirement => lambda {|req| SharedHelpers.pretty_dependency(req) },
|
330
|
-
:additional_message_for_conflict => lambda do |o, name, conflict|
|
331
|
-
if name == "bundler"
|
332
|
-
o << %(\n Current Bundler version:\n bundler (#{Bundler::VERSION}))
|
333
|
-
|
334
|
-
conflict_dependency = conflict.requirement
|
335
|
-
conflict_requirement = conflict_dependency.requirement
|
336
|
-
other_bundler_required = !conflict_requirement.satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
337
|
-
|
338
|
-
if other_bundler_required
|
339
|
-
o << "\n\n"
|
340
|
-
|
341
|
-
candidate_specs = source_for(:default_bundler).specs.search(conflict_dependency)
|
342
|
-
if candidate_specs.any?
|
343
|
-
target_version = candidate_specs.last.version
|
344
|
-
new_command = [File.basename($PROGRAM_NAME), "_#{target_version}_", *ARGV].join(" ")
|
345
|
-
o << "Your bundle requires a different version of Bundler than the one you're running.\n"
|
346
|
-
o << "Install the necessary version with `gem install bundler:#{target_version}` and rerun bundler using `#{new_command}`\n"
|
347
|
-
else
|
348
|
-
o << "Your bundle requires a different version of Bundler than the one you're running, and that version could not be found.\n"
|
349
|
-
end
|
350
|
-
end
|
351
|
-
elsif conflict.locked_requirement
|
352
|
-
o << "\n"
|
353
|
-
o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
|
354
|
-
o << %(the gems in your Gemfile, which may resolve the conflict.\n)
|
355
|
-
elsif !conflict.existing
|
356
|
-
o << "\n"
|
357
|
-
|
358
|
-
relevant_source = conflict.requirement.source || source_for(name)
|
359
|
-
|
360
|
-
metadata_requirement = name.end_with?("\0")
|
361
|
-
|
362
|
-
o << "Could not find gem '" unless metadata_requirement
|
363
|
-
o << SharedHelpers.pretty_dependency(conflict.requirement)
|
364
|
-
o << "'" unless metadata_requirement
|
365
|
-
if conflict.requirement_trees.first.size > 1
|
366
|
-
o << ", which is required by "
|
367
|
-
o << "gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
|
368
|
-
end
|
369
|
-
o << " "
|
370
|
-
|
371
|
-
o << if metadata_requirement
|
372
|
-
"is not available in #{relevant_source}"
|
373
|
-
else
|
374
|
-
"in #{relevant_source.to_err}.\n"
|
375
|
-
end
|
376
|
-
end
|
377
|
-
end,
|
378
|
-
:version_for_spec => lambda {|spec| spec.version },
|
379
|
-
:incompatible_version_message_for_conflict => lambda do |name, _conflict|
|
380
|
-
if name.end_with?("\0")
|
381
|
-
%(#{solver_name} found conflicting requirements for the #{name} version:)
|
382
|
-
else
|
383
|
-
%(#{solver_name} could not find compatible versions for #{possibility_type} "#{name}":)
|
384
|
-
end
|
385
|
-
end
|
386
|
-
)
|
387
499
|
end
|
388
500
|
end
|
389
501
|
end
|