bundler 1.13.6 → 1.17.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +554 -9
- data/README.md +28 -5
- data/bundler.gemspec +40 -11
- data/exe/bundle +4 -8
- data/exe/bundle_ruby +4 -3
- data/lib/bundler.rb +162 -68
- data/lib/bundler/build_metadata.rb +53 -0
- data/lib/bundler/capistrano.rb +5 -0
- data/lib/bundler/cli.rb +360 -118
- data/lib/bundler/cli/add.rb +35 -0
- data/lib/bundler/cli/binstubs.rb +18 -10
- data/lib/bundler/cli/cache.rb +6 -5
- data/lib/bundler/cli/check.rb +4 -6
- data/lib/bundler/cli/clean.rb +6 -7
- data/lib/bundler/cli/common.rb +47 -1
- data/lib/bundler/cli/config.rb +26 -7
- data/lib/bundler/cli/console.rb +2 -1
- data/lib/bundler/cli/doctor.rb +63 -18
- data/lib/bundler/cli/exec.rb +12 -5
- data/lib/bundler/cli/gem.rb +59 -21
- data/lib/bundler/cli/info.rb +50 -0
- data/lib/bundler/cli/init.rb +21 -7
- data/lib/bundler/cli/inject.rb +13 -4
- data/lib/bundler/cli/install.rb +72 -101
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +58 -0
- data/lib/bundler/cli/lock.rb +9 -6
- data/lib/bundler/cli/open.rb +4 -3
- data/lib/bundler/cli/outdated.rb +175 -60
- data/lib/bundler/cli/package.rb +9 -6
- data/lib/bundler/cli/platform.rb +2 -1
- data/lib/bundler/cli/plugin.rb +1 -0
- data/lib/bundler/cli/pristine.rb +47 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +2 -2
- data/lib/bundler/cli/update.rb +44 -34
- data/lib/bundler/cli/viz.rb +5 -1
- data/lib/bundler/compact_index_client.rb +109 -0
- data/lib/bundler/compact_index_client/cache.rb +118 -0
- data/lib/bundler/compact_index_client/updater.rb +116 -0
- data/lib/bundler/compatibility_guard.rb +14 -0
- data/lib/bundler/constants.rb +1 -0
- data/lib/bundler/current_ruby.rb +17 -8
- data/lib/bundler/definition.rb +353 -182
- data/lib/bundler/dep_proxy.rb +3 -1
- data/lib/bundler/dependency.rb +22 -10
- data/lib/bundler/deployment.rb +1 -1
- data/lib/bundler/deprecate.rb +15 -3
- data/lib/bundler/dsl.rb +122 -64
- data/lib/bundler/endpoint_specification.rb +13 -3
- data/lib/bundler/env.rb +110 -38
- data/lib/bundler/environment_preserver.rb +27 -6
- data/lib/bundler/errors.rb +24 -0
- data/lib/bundler/feature_flag.rb +74 -0
- data/lib/bundler/fetcher.rb +18 -11
- data/lib/bundler/fetcher/base.rb +1 -0
- data/lib/bundler/fetcher/compact_index.rb +7 -5
- data/lib/bundler/fetcher/dependency.rb +3 -2
- data/lib/bundler/fetcher/downloader.rb +25 -7
- data/lib/bundler/fetcher/index.rb +3 -2
- data/lib/bundler/friendly_errors.rb +33 -7
- data/lib/bundler/gem_helper.rb +25 -11
- data/lib/bundler/gem_helpers.rb +70 -1
- data/lib/bundler/gem_remote_fetcher.rb +1 -0
- data/lib/bundler/gem_tasks.rb +1 -0
- data/lib/bundler/gem_version_promoter.rb +17 -2
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +1 -0
- data/lib/bundler/index.rb +28 -15
- data/lib/bundler/injector.rb +216 -33
- data/lib/bundler/inline.rb +12 -12
- data/lib/bundler/installer.rb +139 -53
- data/lib/bundler/installer/gem_installer.rb +15 -5
- data/lib/bundler/installer/parallel_installer.rb +113 -28
- data/lib/bundler/installer/standalone.rb +1 -0
- data/lib/bundler/lazy_specification.rb +31 -3
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +50 -37
- data/lib/bundler/match_platform.rb +13 -3
- data/lib/bundler/mirror.rb +10 -5
- data/lib/bundler/plugin.rb +22 -8
- data/lib/bundler/plugin/api.rb +2 -1
- data/lib/bundler/plugin/api/source.rb +17 -4
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +9 -2
- data/lib/bundler/plugin/installer.rb +7 -6
- data/lib/bundler/plugin/source_list.rb +7 -8
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +10 -0
- data/lib/bundler/remote_specification.rb +30 -1
- data/lib/bundler/resolver.rb +187 -194
- data/lib/bundler/resolver/spec_group.rb +106 -0
- data/lib/bundler/retry.rb +5 -1
- data/lib/bundler/ruby_dsl.rb +1 -0
- data/lib/bundler/ruby_version.rb +12 -2
- data/lib/bundler/rubygems_ext.rb +23 -8
- data/lib/bundler/rubygems_gem_installer.rb +90 -0
- data/lib/bundler/rubygems_integration.rb +193 -70
- data/lib/bundler/runtime.rb +39 -22
- data/lib/bundler/settings.rb +245 -85
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +4 -7
- data/lib/bundler/shared_helpers.rb +183 -40
- data/lib/bundler/similarity_detector.rb +1 -0
- data/lib/bundler/source.rb +58 -1
- data/lib/bundler/source/gemspec.rb +1 -0
- data/lib/bundler/source/git.rb +52 -23
- data/lib/bundler/source/git/git_proxy.rb +30 -14
- data/lib/bundler/source/metadata.rb +62 -0
- data/lib/bundler/source/path.rb +42 -16
- data/lib/bundler/source/path/installer.rb +4 -2
- data/lib/bundler/source/rubygems.rb +171 -82
- data/lib/bundler/source/rubygems/remote.rb +12 -2
- data/lib/bundler/source_list.rb +75 -15
- data/lib/bundler/spec_set.rb +67 -32
- data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
- data/lib/bundler/stub_specification.rb +86 -2
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +13 -1
- data/lib/bundler/templates/Executable.bundler +105 -0
- data/lib/bundler/templates/Executable.standalone +5 -5
- data/lib/bundler/templates/Gemfile +3 -0
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -2
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
- data/lib/bundler/templates/newgem/README.md.tt +14 -8
- data/lib/bundler/templates/newgem/Rakefile.tt +5 -5
- data/lib/bundler/templates/newgem/bin/console.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
- data/lib/bundler/templates/newgem/gitignore.tt +5 -1
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -6
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +4 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -12
- data/lib/bundler/templates/newgem/rspec.tt +1 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -3
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +13 -1
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +1 -1
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +3 -3
- data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
- data/lib/bundler/ui.rb +1 -0
- data/lib/bundler/ui/rg_proxy.rb +1 -0
- data/lib/bundler/ui/shell.rb +30 -10
- data/lib/bundler/ui/silent.rb +21 -1
- data/lib/bundler/uri_credentials_filter.rb +1 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +26 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +2 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +12 -4
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +11 -3
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +13 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +18 -5
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +499 -128
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/faster.rb +1 -0
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +27 -24
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent/ssl_reuse.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +46 -21
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +24 -22
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +66 -18
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +17 -15
- data/lib/bundler/vendor/thor/lib/thor/base.rb +55 -32
- data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -11
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +7 -5
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +94 -63
- data/lib/bundler/vendor/thor/lib/thor/error.rb +3 -3
- data/lib/bundler/vendor/thor/lib/thor/group.rb +13 -13
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +4 -5
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +16 -16
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +42 -21
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -10
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +31 -29
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +49 -33
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendored_fileutils.rb +9 -0
- data/lib/bundler/vendored_molinillo.rb +1 -0
- data/lib/bundler/vendored_persistent.rb +43 -3
- data/lib/bundler/vendored_thor.rb +6 -2
- data/lib/bundler/version.rb +19 -2
- data/lib/bundler/version_ranges.rb +76 -0
- data/lib/bundler/vlad.rb +5 -0
- data/lib/bundler/worker.rb +30 -6
- data/lib/bundler/yaml_serializer.rb +4 -4
- data/man/bundle-add.1 +58 -0
- data/man/bundle-add.1.txt +52 -0
- data/man/bundle-add.ronn +40 -0
- data/{lib/bundler/man/bundle-binstubs → man/bundle-binstubs.1} +11 -1
- data/man/bundle-binstubs.1.txt +48 -0
- data/man/bundle-binstubs.ronn +15 -1
- data/man/bundle-check.1 +31 -0
- data/man/bundle-check.1.txt +33 -0
- data/man/bundle-check.ronn +26 -0
- data/man/bundle-clean.1 +24 -0
- data/man/bundle-clean.1.txt +26 -0
- data/man/bundle-clean.ronn +18 -0
- data/man/bundle-config.1 +497 -0
- data/man/bundle-config.1.txt +529 -0
- data/man/bundle-config.ronn +233 -61
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/{lib/bundler/man/bundle-exec → man/bundle-exec.1} +6 -3
- data/man/bundle-exec.1.txt +178 -0
- data/man/bundle-exec.ronn +10 -3
- data/{lib/bundler/man/bundle-gem → man/bundle-gem.1} +4 -4
- data/man/bundle-gem.1.txt +91 -0
- data/man/bundle-gem.ronn +3 -2
- data/man/bundle-info.1 +20 -0
- data/man/bundle-info.1.txt +21 -0
- data/man/bundle-info.ronn +17 -0
- data/man/bundle-init.1 +25 -0
- data/man/bundle-init.1.txt +34 -0
- data/man/bundle-init.ronn +29 -0
- data/man/bundle-inject.1 +33 -0
- data/man/bundle-inject.1.txt +32 -0
- data/man/bundle-inject.ronn +22 -0
- data/{lib/bundler/man/bundle-install → man/bundle-install.1} +32 -29
- data/man/bundle-install.1.txt +396 -0
- data/man/bundle-install.ronn +45 -36
- data/man/bundle-list.1 +50 -0
- data/man/bundle-list.1.txt +43 -0
- data/man/bundle-list.ronn +33 -0
- data/{lib/bundler/man/bundle-lock → man/bundle-lock.1} +43 -2
- data/man/bundle-lock.1.txt +93 -0
- data/man/bundle-lock.ronn +47 -0
- data/man/bundle-open.1 +32 -0
- data/man/bundle-open.1.txt +29 -0
- data/man/bundle-open.ronn +19 -0
- data/man/bundle-outdated.1 +155 -0
- data/man/bundle-outdated.1.txt +131 -0
- data/man/bundle-outdated.ronn +111 -0
- data/{lib/bundler/man/bundle-package → man/bundle-package.1} +6 -3
- data/man/bundle-package.1.txt +79 -0
- data/man/bundle-package.ronn +7 -2
- data/{lib/bundler/man/bundle-platform → man/bundle-platform.1} +1 -1
- data/man/bundle-platform.1.txt +57 -0
- data/man/bundle-pristine.1 +34 -0
- data/man/bundle-pristine.1.txt +44 -0
- data/man/bundle-pristine.ronn +34 -0
- data/man/bundle-remove.1 +31 -0
- data/man/bundle-remove.1.txt +34 -0
- data/man/bundle-remove.ronn +23 -0
- data/man/bundle-show.1 +23 -0
- data/man/bundle-show.1.txt +27 -0
- data/man/bundle-show.ronn +21 -0
- data/man/bundle-update.1 +394 -0
- data/man/bundle-update.1.txt +391 -0
- data/man/bundle-update.ronn +172 -16
- data/man/bundle-viz.1 +39 -0
- data/man/bundle-viz.1.txt +39 -0
- data/man/bundle-viz.ronn +30 -0
- data/{lib/bundler/man/bundle → man/bundle.1} +44 -28
- data/man/bundle.1.txt +116 -0
- data/man/bundle.ronn +39 -27
- data/{lib/bundler/man → man}/gemfile.5 +67 -84
- data/man/gemfile.5.ronn +77 -55
- data/man/gemfile.5.txt +653 -0
- data/man/index.txt +25 -8
- metadata +118 -58
- data/.codeclimate.yml +0 -25
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -128
- data/.rubocop_todo.yml +0 -248
- data/.travis.yml +0 -108
- data/CODE_OF_CONDUCT.md +0 -42
- data/CONTRIBUTING.md +0 -36
- data/DEVELOPMENT.md +0 -148
- data/ISSUES.md +0 -100
- data/Rakefile +0 -333
- data/bin/rake +0 -19
- data/bin/rspec +0 -15
- data/bin/rubocop +0 -17
- data/bin/with_rubygems +0 -39
- data/lib/bundler/man/bundle-binstubs.txt +0 -33
- data/lib/bundler/man/bundle-config +0 -254
- data/lib/bundler/man/bundle-config.txt +0 -282
- data/lib/bundler/man/bundle-exec.txt +0 -171
- data/lib/bundler/man/bundle-gem.txt +0 -90
- data/lib/bundler/man/bundle-install.txt +0 -385
- data/lib/bundler/man/bundle-lock.txt +0 -52
- data/lib/bundler/man/bundle-package.txt +0 -74
- data/lib/bundler/man/bundle-platform.txt +0 -57
- data/lib/bundler/man/bundle-update +0 -221
- data/lib/bundler/man/bundle-update.txt +0 -227
- data/lib/bundler/man/bundle.txt +0 -104
- data/lib/bundler/man/gemfile.5.txt +0 -636
- data/lib/bundler/postit_trampoline.rb +0 -68
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +0 -79
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +0 -112
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +0 -80
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +0 -4
- data/lib/bundler/vendor/postit/lib/postit.rb +0 -15
- data/lib/bundler/vendor/postit/lib/postit/environment.rb +0 -44
- data/lib/bundler/vendor/postit/lib/postit/installer.rb +0 -28
- data/lib/bundler/vendor/postit/lib/postit/parser.rb +0 -21
- data/lib/bundler/vendor/postit/lib/postit/setup.rb +0 -12
- data/lib/bundler/vendor/postit/lib/postit/version.rb +0 -3
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Resolver
|
5
|
+
class SpecGroup
|
6
|
+
include GemHelpers
|
7
|
+
|
8
|
+
attr_accessor :name, :version, :source
|
9
|
+
attr_accessor :ignores_bundler_dependencies
|
10
|
+
|
11
|
+
def initialize(all_specs)
|
12
|
+
raise ArgumentError, "cannot initialize with an empty value" unless exemplary_spec = all_specs.first
|
13
|
+
@name = exemplary_spec.name
|
14
|
+
@version = exemplary_spec.version
|
15
|
+
@source = exemplary_spec.source
|
16
|
+
|
17
|
+
@activated_platforms = []
|
18
|
+
@dependencies = nil
|
19
|
+
@specs = Hash.new do |specs, platform|
|
20
|
+
specs[platform] = select_best_platform_match(all_specs, platform)
|
21
|
+
end
|
22
|
+
@ignores_bundler_dependencies = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_specs
|
26
|
+
@activated_platforms.map do |p|
|
27
|
+
next unless s = @specs[p]
|
28
|
+
lazy_spec = LazySpecification.new(name, version, s.platform, source)
|
29
|
+
lazy_spec.dependencies.replace s.dependencies
|
30
|
+
lazy_spec
|
31
|
+
end.compact
|
32
|
+
end
|
33
|
+
|
34
|
+
def activate_platform!(platform)
|
35
|
+
return unless for?(platform)
|
36
|
+
return if @activated_platforms.include?(platform)
|
37
|
+
@activated_platforms << platform
|
38
|
+
end
|
39
|
+
|
40
|
+
def for?(platform)
|
41
|
+
spec = @specs[platform]
|
42
|
+
!spec.nil?
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
@to_s ||= "#{name} (#{version})"
|
47
|
+
end
|
48
|
+
|
49
|
+
def dependencies_for_activated_platforms
|
50
|
+
dependencies = @activated_platforms.map {|p| __dependencies[p] }
|
51
|
+
metadata_dependencies = @activated_platforms.map do |platform|
|
52
|
+
metadata_dependencies(@specs[platform], platform)
|
53
|
+
end
|
54
|
+
dependencies.concat(metadata_dependencies).flatten
|
55
|
+
end
|
56
|
+
|
57
|
+
def ==(other)
|
58
|
+
return unless other.is_a?(SpecGroup)
|
59
|
+
name == other.name &&
|
60
|
+
version == other.version &&
|
61
|
+
source == other.source
|
62
|
+
end
|
63
|
+
|
64
|
+
def eql?(other)
|
65
|
+
name.eql?(other.name) &&
|
66
|
+
version.eql?(other.version) &&
|
67
|
+
source.eql?(other.source)
|
68
|
+
end
|
69
|
+
|
70
|
+
def hash
|
71
|
+
to_s.hash ^ source.hash
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def __dependencies
|
77
|
+
@dependencies = Hash.new do |dependencies, platform|
|
78
|
+
dependencies[platform] = []
|
79
|
+
if spec = @specs[platform]
|
80
|
+
spec.dependencies.each do |dep|
|
81
|
+
next if dep.type == :development
|
82
|
+
next if @ignores_bundler_dependencies && dep.name == "bundler".freeze
|
83
|
+
dependencies[platform] << DepProxy.new(dep, platform)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
dependencies[platform]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def metadata_dependencies(spec, platform)
|
91
|
+
return [] unless spec
|
92
|
+
# Only allow endpoint specifications since they won't hit the network to
|
93
|
+
# fetch the full gemspec when calling required_ruby_version
|
94
|
+
return [] if !spec.is_a?(EndpointSpecification) && !spec.is_a?(Gem::Specification)
|
95
|
+
dependencies = []
|
96
|
+
if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
|
97
|
+
dependencies << DepProxy.new(Gem::Dependency.new("ruby\0", spec.required_ruby_version), platform)
|
98
|
+
end
|
99
|
+
if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none?
|
100
|
+
dependencies << DepProxy.new(Gem::Dependency.new("rubygems\0", spec.required_rubygems_version), platform)
|
101
|
+
end
|
102
|
+
dependencies
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
data/lib/bundler/retry.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Bundler
|
3
4
|
# General purpose class for retrying code that may fail
|
4
5
|
class Retry
|
@@ -43,7 +44,10 @@ module Bundler
|
|
43
44
|
|
44
45
|
def fail_attempt(e)
|
45
46
|
@failed = true
|
46
|
-
|
47
|
+
if last_attempt? || @exceptions.any? {|k| e.is_a?(k) }
|
48
|
+
Bundler.ui.info "" unless Bundler.ui.debug?
|
49
|
+
raise e
|
50
|
+
end
|
47
51
|
return true unless name
|
48
52
|
Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this
|
49
53
|
Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
|
data/lib/bundler/ruby_dsl.rb
CHANGED
data/lib/bundler/ruby_version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Bundler
|
3
4
|
class RubyVersion
|
4
5
|
attr_reader :versions,
|
@@ -21,7 +22,11 @@ module Bundler
|
|
21
22
|
# must not be specified, or the engine version
|
22
23
|
# specified must match the version.
|
23
24
|
|
24
|
-
@versions
|
25
|
+
@versions = Array(versions).map do |v|
|
26
|
+
op, v = Gem::Requirement.parse(v)
|
27
|
+
op == "=" ? v.to_s : "#{op} #{v}"
|
28
|
+
end
|
29
|
+
|
25
30
|
@gem_version = Gem::Requirement.create(@versions.first).requirements.first.last
|
26
31
|
@input_engine = engine && engine.to_s
|
27
32
|
@engine = engine && engine.to_s || "ruby"
|
@@ -113,7 +118,7 @@ module Bundler
|
|
113
118
|
when "jruby"
|
114
119
|
JRUBY_VERSION.dup
|
115
120
|
else
|
116
|
-
|
121
|
+
RUBY_ENGINE_VERSION.dup
|
117
122
|
end
|
118
123
|
patchlevel = RUBY_PATCHLEVEL.to_s
|
119
124
|
|
@@ -128,6 +133,11 @@ module Bundler
|
|
128
133
|
end
|
129
134
|
end
|
130
135
|
|
136
|
+
def exact?
|
137
|
+
return @exact if defined?(@exact)
|
138
|
+
@exact = versions.all? {|v| Gem::Requirement.create(v).exact? }
|
139
|
+
end
|
140
|
+
|
131
141
|
private
|
132
142
|
|
133
143
|
def matches?(requirements, version)
|
data/lib/bundler/rubygems_ext.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "pathname"
|
3
4
|
|
4
5
|
if defined?(Gem::QuickLoader)
|
@@ -14,7 +15,7 @@ begin
|
|
14
15
|
# shouldn't be deferred.
|
15
16
|
require "rubygems/source"
|
16
17
|
rescue LoadError
|
17
|
-
# Not available before
|
18
|
+
# Not available before RubyGems 2.0.0, ignore
|
18
19
|
nil
|
19
20
|
end
|
20
21
|
|
@@ -42,7 +43,11 @@ module Gem
|
|
42
43
|
attr_writer :full_gem_path unless instance_methods.include?(:full_gem_path=)
|
43
44
|
|
44
45
|
def full_gem_path
|
45
|
-
|
46
|
+
# this cannot check source.is_a?(Bundler::Plugin::API::Source)
|
47
|
+
# because that _could_ trip the autoload, and if there are unresolved
|
48
|
+
# gems at that time, this method could be called inside another require,
|
49
|
+
# thus raising with that constant being undefined. Better to check a method
|
50
|
+
if source.respond_to?(:path) || (source.respond_to?(:bundler_plugin_api_source?) && source.bundler_plugin_api_source?)
|
46
51
|
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.untaint
|
47
52
|
else
|
48
53
|
rg_full_gem_path
|
@@ -131,7 +136,7 @@ module Gem
|
|
131
136
|
end
|
132
137
|
|
133
138
|
class Dependency
|
134
|
-
attr_accessor :source, :groups
|
139
|
+
attr_accessor :source, :groups, :all_sources
|
135
140
|
|
136
141
|
alias_method :eql?, :==
|
137
142
|
|
@@ -142,19 +147,19 @@ module Gem
|
|
142
147
|
end
|
143
148
|
|
144
149
|
def to_yaml_properties
|
145
|
-
instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
|
150
|
+
instance_variables.reject {|p| ["@source", "@groups", "@all_sources"].include?(p.to_s) }
|
146
151
|
end
|
147
152
|
|
148
153
|
def to_lock
|
149
154
|
out = String.new(" #{name}")
|
150
|
-
unless requirement
|
155
|
+
unless requirement.none?
|
151
156
|
reqs = requirement.requirements.map {|o, v| "#{o} #{v}" }.sort.reverse
|
152
157
|
out << " (#{reqs.join(", ")})"
|
153
158
|
end
|
154
159
|
out
|
155
160
|
end
|
156
161
|
|
157
|
-
# Backport of performance enhancement added to
|
162
|
+
# Backport of performance enhancement added to RubyGems 1.4
|
158
163
|
def matches_spec?(spec)
|
159
164
|
# name can be a Regexp, so use ===
|
160
165
|
return false unless name === spec.name
|
@@ -165,10 +170,20 @@ module Gem
|
|
165
170
|
end
|
166
171
|
|
167
172
|
class Requirement
|
168
|
-
# Backport of performance enhancement added to
|
173
|
+
# Backport of performance enhancement added to RubyGems 1.4
|
169
174
|
def none?
|
170
|
-
|
175
|
+
# note that it might be tempting to replace with with RubyGems 2.0's
|
176
|
+
# improved implementation. Don't. It requires `DefaultRequirement` to be
|
177
|
+
# defined, and more importantantly, these overrides are not used when the
|
178
|
+
# running RubyGems defines these methods
|
179
|
+
to_s == ">= 0"
|
171
180
|
end unless allocate.respond_to?(:none?)
|
181
|
+
|
182
|
+
# Backport of performance enhancement added to RubyGems 2.2
|
183
|
+
def exact?
|
184
|
+
return false unless @requirements.size == 1
|
185
|
+
@requirements[0][0] == "="
|
186
|
+
end unless allocate.respond_to?(:exact?)
|
172
187
|
end
|
173
188
|
|
174
189
|
class Platform
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "rubygems/installer"
|
3
4
|
|
4
5
|
module Bundler
|
@@ -9,8 +10,97 @@ module Bundler
|
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
13
|
+
attr_reader :options
|
14
|
+
|
15
|
+
def initialize(gem, options = {})
|
16
|
+
@options = {}
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
12
20
|
def check_executable_overwrite(filename)
|
13
21
|
# Bundler needs to install gems regardless of binstub overwriting
|
14
22
|
end
|
23
|
+
|
24
|
+
def pre_install_checks
|
25
|
+
super && validate_bundler_checksum(options[:bundler_expected_checksum])
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_extensions
|
29
|
+
extension_cache_path = options[:bundler_extension_cache_path]
|
30
|
+
return super unless extension_cache_path && extension_dir = Bundler.rubygems.spec_extension_dir(spec)
|
31
|
+
|
32
|
+
extension_dir = Pathname.new(extension_dir)
|
33
|
+
build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
|
34
|
+
if build_complete && !options[:force]
|
35
|
+
SharedHelpers.filesystem_access(extension_dir.parent, &:mkpath)
|
36
|
+
SharedHelpers.filesystem_access(extension_cache_path) do
|
37
|
+
FileUtils.cp_r extension_cache_path, spec.extension_dir
|
38
|
+
end
|
39
|
+
else
|
40
|
+
super
|
41
|
+
if extension_dir.directory? # not made for gems without extensions
|
42
|
+
SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
|
43
|
+
SharedHelpers.filesystem_access(extension_cache_path) do
|
44
|
+
FileUtils.cp_r extension_dir, extension_cache_path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def validate_bundler_checksum(checksum)
|
53
|
+
return true if Bundler.settings[:disable_checksum_validation]
|
54
|
+
return true unless checksum
|
55
|
+
return true unless source = @package.instance_variable_get(:@gem)
|
56
|
+
return true unless source.respond_to?(:with_read_io)
|
57
|
+
digest = source.with_read_io do |io|
|
58
|
+
digest = SharedHelpers.digest(:SHA256).new
|
59
|
+
digest << io.read(16_384) until io.eof?
|
60
|
+
io.rewind
|
61
|
+
send(checksum_type(checksum), digest)
|
62
|
+
end
|
63
|
+
unless digest == checksum
|
64
|
+
raise SecurityError, <<-MESSAGE
|
65
|
+
Bundler cannot continue installing #{spec.name} (#{spec.version}).
|
66
|
+
The checksum for the downloaded `#{spec.full_name}.gem` does not match \
|
67
|
+
the checksum given by the server. This means the contents of the downloaded \
|
68
|
+
gem is different from what was uploaded to the server, and could be a potential security issue.
|
69
|
+
|
70
|
+
To resolve this issue:
|
71
|
+
1. delete the downloaded gem located at: `#{spec.gem_dir}/#{spec.full_name}.gem`
|
72
|
+
2. run `bundle install`
|
73
|
+
|
74
|
+
If you wish to continue installing the downloaded gem, and are certain it does not pose a \
|
75
|
+
security issue despite the mismatching checksum, do the following:
|
76
|
+
1. run `bundle config disable_checksum_validation true` to turn off checksum verification
|
77
|
+
2. run `bundle install`
|
78
|
+
|
79
|
+
(More info: The expected SHA256 checksum was #{checksum.inspect}, but the \
|
80
|
+
checksum for the downloaded gem was #{digest.inspect}.)
|
81
|
+
MESSAGE
|
82
|
+
end
|
83
|
+
true
|
84
|
+
end
|
85
|
+
|
86
|
+
def checksum_type(checksum)
|
87
|
+
case checksum.length
|
88
|
+
when 64 then :hexdigest!
|
89
|
+
when 44 then :base64digest!
|
90
|
+
else raise InstallError, "The given checksum for #{spec.full_name} (#{checksum.inspect}) is not a valid SHA256 hexdigest nor base64digest"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def hexdigest!(digest)
|
95
|
+
digest.hexdigest!
|
96
|
+
end
|
97
|
+
|
98
|
+
def base64digest!(digest)
|
99
|
+
if digest.respond_to?(:base64digest!)
|
100
|
+
digest.base64digest!
|
101
|
+
else
|
102
|
+
[digest.digest!].pack("m0")
|
103
|
+
end
|
104
|
+
end
|
15
105
|
end
|
16
106
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "monitor"
|
3
4
|
require "rubygems"
|
4
5
|
require "rubygems/config_file"
|
@@ -71,8 +72,34 @@ module Bundler
|
|
71
72
|
spec.installed_by_version = Gem::Version.create(installed_by_version)
|
72
73
|
end
|
73
74
|
|
74
|
-
def spec_missing_extensions?(spec)
|
75
|
-
|
75
|
+
def spec_missing_extensions?(spec, default = true)
|
76
|
+
return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
|
77
|
+
|
78
|
+
return false if spec_default_gem?(spec)
|
79
|
+
return false if spec.extensions.empty?
|
80
|
+
|
81
|
+
default
|
82
|
+
end
|
83
|
+
|
84
|
+
def spec_default_gem?(spec)
|
85
|
+
spec.respond_to?(:default_gem?) && spec.default_gem?
|
86
|
+
end
|
87
|
+
|
88
|
+
def spec_matches_for_glob(spec, glob)
|
89
|
+
return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
|
90
|
+
|
91
|
+
spec.load_paths.map do |lp|
|
92
|
+
Dir["#{lp}/#{glob}#{suffix_pattern}"]
|
93
|
+
end.flatten(1)
|
94
|
+
end
|
95
|
+
|
96
|
+
def spec_extension_dir(spec)
|
97
|
+
return unless spec.respond_to?(:extension_dir)
|
98
|
+
spec.extension_dir
|
99
|
+
end
|
100
|
+
|
101
|
+
def stub_set_spec(stub, spec)
|
102
|
+
stub.instance_variable_set(:@spec, spec)
|
76
103
|
end
|
77
104
|
|
78
105
|
def path(obj)
|
@@ -80,6 +107,7 @@ module Bundler
|
|
80
107
|
end
|
81
108
|
|
82
109
|
def platforms
|
110
|
+
return [Gem::Platform::RUBY] if Bundler.settings[:force_ruby_platform]
|
83
111
|
Gem.platforms
|
84
112
|
end
|
85
113
|
|
@@ -104,7 +132,11 @@ module Bundler
|
|
104
132
|
end
|
105
133
|
|
106
134
|
def inflate(obj)
|
107
|
-
Gem
|
135
|
+
if defined?(Gem::Util)
|
136
|
+
Gem::Util.inflate(obj)
|
137
|
+
else
|
138
|
+
Gem.inflate(obj)
|
139
|
+
end
|
108
140
|
end
|
109
141
|
|
110
142
|
def sources=(val)
|
@@ -144,6 +176,10 @@ module Bundler
|
|
144
176
|
Gem.post_reset_hooks
|
145
177
|
end
|
146
178
|
|
179
|
+
def suffix_pattern
|
180
|
+
Gem.suffix_pattern
|
181
|
+
end
|
182
|
+
|
147
183
|
def gem_cache
|
148
184
|
gem_path.map {|p| File.expand_path("cache", p) }
|
149
185
|
end
|
@@ -151,7 +187,7 @@ module Bundler
|
|
151
187
|
def spec_cache_dirs
|
152
188
|
@spec_cache_dirs ||= begin
|
153
189
|
dirs = gem_path.map {|dir| File.join(dir, "specifications") }
|
154
|
-
dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in
|
190
|
+
dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in RubyGems 2.0.3 or earlier
|
155
191
|
dirs.uniq.select {|dir| File.directory? dir }
|
156
192
|
end
|
157
193
|
end
|
@@ -165,7 +201,7 @@ module Bundler
|
|
165
201
|
end
|
166
202
|
|
167
203
|
def repository_subdirectories
|
168
|
-
%w
|
204
|
+
%w[cache doc gems specifications]
|
169
205
|
end
|
170
206
|
|
171
207
|
def clear_paths
|
@@ -176,8 +212,12 @@ module Bundler
|
|
176
212
|
Gem.bin_path(gem, bin, ver)
|
177
213
|
end
|
178
214
|
|
215
|
+
def path_separator
|
216
|
+
File::PATH_SEPARATOR
|
217
|
+
end
|
218
|
+
|
179
219
|
def preserve_paths
|
180
|
-
# this is a no-op outside of
|
220
|
+
# this is a no-op outside of RubyGems 1.8
|
181
221
|
yield
|
182
222
|
end
|
183
223
|
|
@@ -194,6 +234,14 @@ module Bundler
|
|
194
234
|
end
|
195
235
|
end
|
196
236
|
|
237
|
+
def load_plugins
|
238
|
+
Gem.load_plugins if Gem.respond_to?(:load_plugins)
|
239
|
+
end
|
240
|
+
|
241
|
+
def load_plugin_files(files)
|
242
|
+
Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files)
|
243
|
+
end
|
244
|
+
|
197
245
|
def ui=(obj)
|
198
246
|
Gem::DefaultUserInteraction.ui = obj
|
199
247
|
end
|
@@ -203,6 +251,7 @@ module Bundler
|
|
203
251
|
end
|
204
252
|
|
205
253
|
def fetch_specs(all, pre, &blk)
|
254
|
+
require "rubygems/spec_fetcher"
|
206
255
|
specs = Gem::SpecFetcher.new.list(all, pre)
|
207
256
|
specs.each { yield } if block_given?
|
208
257
|
specs
|
@@ -214,9 +263,9 @@ module Bundler
|
|
214
263
|
{} # if we can't download them, there aren't any
|
215
264
|
end
|
216
265
|
|
217
|
-
# TODO: This is for older versions of
|
266
|
+
# TODO: This is for older versions of RubyGems... should we support the
|
218
267
|
# X-Gemfile-Source header on these old versions?
|
219
|
-
# Maybe the newer implementation will work on older
|
268
|
+
# Maybe the newer implementation will work on older RubyGems?
|
220
269
|
# It seems difficult to keep this implementation and still send the header.
|
221
270
|
def fetch_all_remote_specs(remote)
|
222
271
|
old_sources = Bundler.rubygems.sources
|
@@ -243,6 +292,10 @@ module Bundler
|
|
243
292
|
end
|
244
293
|
end
|
245
294
|
|
295
|
+
def install_with_build_args(args)
|
296
|
+
with_build_args(args) { yield }
|
297
|
+
end
|
298
|
+
|
246
299
|
def gem_from_path(path, policy = nil)
|
247
300
|
require "rubygems/format"
|
248
301
|
Gem::Format.from_file_by_path(path, policy)
|
@@ -250,6 +303,7 @@ module Bundler
|
|
250
303
|
|
251
304
|
def spec_from_gem(path, policy = nil)
|
252
305
|
require "rubygems/security"
|
306
|
+
require "bundler/psyched_yaml"
|
253
307
|
gem_from_path(path, security_policies[policy]).spec
|
254
308
|
rescue Gem::Package::FormatError
|
255
309
|
raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
|
@@ -277,13 +331,13 @@ module Bundler
|
|
277
331
|
def download_gem(spec, uri, path)
|
278
332
|
uri = Bundler.settings.mirror_for(uri)
|
279
333
|
fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy])
|
280
|
-
Bundler::Retry.new("download gem #{uri}"
|
334
|
+
Bundler::Retry.new("download gem from #{uri}").attempts do
|
281
335
|
fetcher.download(spec, uri, path)
|
282
336
|
end
|
283
337
|
end
|
284
338
|
|
285
339
|
def security_policy_keys
|
286
|
-
%w
|
340
|
+
%w[High Medium Low AlmostNo No].map {|level| "#{level}Security" }
|
287
341
|
end
|
288
342
|
|
289
343
|
def security_policies
|
@@ -305,53 +359,57 @@ module Bundler
|
|
305
359
|
end
|
306
360
|
end
|
307
361
|
|
308
|
-
def
|
362
|
+
def binstubs_call_gem?
|
363
|
+
true
|
364
|
+
end
|
365
|
+
|
366
|
+
def stubs_provide_full_functionality?
|
367
|
+
false
|
368
|
+
end
|
369
|
+
|
370
|
+
def replace_gem(specs, specs_by_name)
|
309
371
|
reverse_rubygems_kernel_mixin
|
310
372
|
|
311
|
-
executables =
|
373
|
+
executables = nil
|
312
374
|
|
313
375
|
kernel = (class << ::Kernel; self; end)
|
314
376
|
[kernel, ::Kernel].each do |kernel_class|
|
315
377
|
redefine_method(kernel_class, :gem) do |dep, *reqs|
|
316
|
-
|
378
|
+
executables ||= specs.map(&:executables).flatten if ::Bundler.rubygems.binstubs_call_gem?
|
379
|
+
if executables && executables.include?(File.basename(caller.first.split(":").first))
|
317
380
|
break
|
318
381
|
end
|
382
|
+
|
319
383
|
reqs.pop if reqs.last.is_a?(Hash)
|
320
384
|
|
321
385
|
unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
|
322
386
|
dep = Gem::Dependency.new(dep, reqs)
|
323
387
|
end
|
324
388
|
|
325
|
-
spec =
|
326
|
-
|
327
|
-
if spec.nil?
|
328
|
-
|
329
|
-
e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
|
330
|
-
e.name = dep.name
|
331
|
-
if e.respond_to?(:requirement=)
|
332
|
-
e.requirement = dep.requirement
|
333
|
-
else
|
334
|
-
e.version_requirement = dep.requirement
|
335
|
-
end
|
336
|
-
raise e
|
337
|
-
elsif dep !~ spec
|
338
|
-
e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
|
339
|
-
"Make sure all dependencies are added to Gemfile."
|
340
|
-
e.name = dep.name
|
341
|
-
if e.respond_to?(:requirement=)
|
342
|
-
e.requirement = dep.requirement
|
343
|
-
else
|
344
|
-
e.version_requirement = dep.requirement
|
345
|
-
end
|
346
|
-
raise e
|
389
|
+
if spec = specs_by_name[dep.name]
|
390
|
+
return true if dep.matches_spec?(spec)
|
347
391
|
end
|
348
392
|
|
349
|
-
|
393
|
+
message = if spec.nil?
|
394
|
+
"#{dep.name} is not part of the bundle." \
|
395
|
+
" Add it to your #{Bundler.default_gemfile.basename}."
|
396
|
+
else
|
397
|
+
"can't activate #{dep}, already activated #{spec.full_name}. " \
|
398
|
+
"Make sure all dependencies are added to Gemfile."
|
399
|
+
end
|
400
|
+
|
401
|
+
e = Gem::LoadError.new(message)
|
402
|
+
e.name = dep.name
|
403
|
+
if e.respond_to?(:requirement=)
|
404
|
+
e.requirement = dep.requirement
|
405
|
+
elsif e.respond_to?(:version_requirement=)
|
406
|
+
e.version_requirement = dep.requirement
|
407
|
+
end
|
408
|
+
raise e
|
350
409
|
end
|
351
410
|
|
352
|
-
#
|
353
|
-
|
354
|
-
kernel_class.send(:public, :gem)
|
411
|
+
# backwards compatibility shim, see https://github.com/bundler/bundler/issues/5102
|
412
|
+
kernel_class.send(:public, :gem) if Bundler.feature_flag.setup_makes_kernel_gem_public?
|
355
413
|
end
|
356
414
|
end
|
357
415
|
|
@@ -378,23 +436,37 @@ module Bundler
|
|
378
436
|
# Used to make bin stubs that are not created by bundler work
|
379
437
|
# under bundler. The new Gem.bin_path only considers gems in
|
380
438
|
# +specs+
|
381
|
-
def replace_bin_path(specs)
|
439
|
+
def replace_bin_path(specs, specs_by_name)
|
382
440
|
gem_class = (class << Gem; self; end)
|
383
441
|
|
384
442
|
redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
|
385
443
|
exec_name = args.first
|
386
444
|
|
445
|
+
spec_with_name = specs_by_name[gem_name]
|
387
446
|
spec = if exec_name
|
388
|
-
|
447
|
+
if spec_with_name && spec_with_name.executables.include?(exec_name)
|
448
|
+
spec_with_name
|
449
|
+
else
|
389
450
|
specs.find {|s| s.executables.include?(exec_name) }
|
451
|
+
end
|
390
452
|
else
|
391
|
-
|
453
|
+
spec_with_name
|
454
|
+
end
|
455
|
+
|
456
|
+
unless spec
|
457
|
+
message = "can't find executable #{exec_name} for gem #{gem_name}"
|
458
|
+
if !exec_name || spec_with_name.nil?
|
459
|
+
message += ". #{gem_name} is not currently included in the bundle, " \
|
460
|
+
"perhaps you meant to add it to your #{Bundler.default_gemfile.basename}?"
|
461
|
+
end
|
462
|
+
raise Gem::Exception, message
|
392
463
|
end
|
393
|
-
|
464
|
+
|
394
465
|
raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name ||= spec.default_executable
|
395
|
-
|
396
|
-
|
397
|
-
|
466
|
+
|
467
|
+
unless spec.name == gem_name
|
468
|
+
Bundler::SharedHelpers.major_deprecation 2,
|
469
|
+
"Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \
|
398
470
|
"You should run `bundle binstub #{gem_name}` " \
|
399
471
|
"to work around a system/bundle conflict."
|
400
472
|
end
|
@@ -408,8 +480,10 @@ module Bundler
|
|
408
480
|
# Copy of Rubygems activate_bin_path impl
|
409
481
|
requirement = args.last
|
410
482
|
spec = find_spec_for_exe name, exec_name, [requirement]
|
411
|
-
|
412
|
-
spec.
|
483
|
+
|
484
|
+
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
|
485
|
+
gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
|
486
|
+
File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
|
413
487
|
end
|
414
488
|
|
415
489
|
redefine_method(gem_class, :bin_path) do |name, *args|
|
@@ -432,21 +506,24 @@ module Bundler
|
|
432
506
|
redefine_method(gem_class, :refresh) {}
|
433
507
|
end
|
434
508
|
|
435
|
-
# Replace or hook into
|
509
|
+
# Replace or hook into RubyGems to provide a bundlerized view
|
436
510
|
# of the world.
|
437
511
|
def replace_entrypoints(specs)
|
438
|
-
|
512
|
+
specs_by_name = specs.reduce({}) do |h, s|
|
513
|
+
h[s.name] = s
|
514
|
+
h
|
515
|
+
end
|
439
516
|
|
517
|
+
replace_gem(specs, specs_by_name)
|
440
518
|
stub_rubygems(specs)
|
441
|
-
|
442
|
-
replace_bin_path(specs)
|
519
|
+
replace_bin_path(specs, specs_by_name)
|
443
520
|
replace_refresh
|
444
521
|
|
445
522
|
Gem.clear_paths
|
446
523
|
end
|
447
524
|
|
448
|
-
# This backports the correct segment generation code from
|
449
|
-
# by monkeypatching it into the method in
|
525
|
+
# This backports the correct segment generation code from RubyGems 1.4+
|
526
|
+
# by monkeypatching it into the method in RubyGems 1.3.6 and 1.3.7.
|
450
527
|
def backport_segment_generation
|
451
528
|
redefine_method(Gem::Version, :segments) do
|
452
529
|
@segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
|
@@ -465,7 +542,7 @@ module Bundler
|
|
465
542
|
end
|
466
543
|
|
467
544
|
# This backports base_dir which replaces installation path
|
468
|
-
#
|
545
|
+
# RubyGems 1.8+
|
469
546
|
def backport_base_dir
|
470
547
|
redefine_method(Gem::Specification, :base_dir) do
|
471
548
|
return Gem.dir unless loaded_from
|
@@ -497,8 +574,10 @@ module Bundler
|
|
497
574
|
@replaced_methods.each do |(sym, klass), method|
|
498
575
|
redefine_method(klass, sym, method)
|
499
576
|
end
|
500
|
-
|
501
|
-
proc.binding.
|
577
|
+
if Binding.public_method_defined?(:source_location)
|
578
|
+
post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
|
579
|
+
else
|
580
|
+
post_reset_hooks.reject! {|proc| proc.binding.eval("__FILE__") == __FILE__ }
|
502
581
|
end
|
503
582
|
@replaced_methods.clear
|
504
583
|
end
|
@@ -534,7 +613,7 @@ module Bundler
|
|
534
613
|
end
|
535
614
|
end
|
536
615
|
|
537
|
-
#
|
616
|
+
# RubyGems 1.4 through 1.6
|
538
617
|
class Legacy < RubygemsIntegration
|
539
618
|
def initialize
|
540
619
|
super
|
@@ -545,7 +624,7 @@ module Bundler
|
|
545
624
|
end
|
546
625
|
|
547
626
|
def stub_rubygems(specs)
|
548
|
-
#
|
627
|
+
# RubyGems versions lower than 1.7 use SourceIndex#from_gems_in
|
549
628
|
source_index_class = (class << Gem::SourceIndex; self; end)
|
550
629
|
redefine_method(source_index_class, :from_gems_in) do |*args|
|
551
630
|
Gem::SourceIndex.new.tap do |source_index|
|
@@ -577,7 +656,7 @@ module Bundler
|
|
577
656
|
end
|
578
657
|
end
|
579
658
|
|
580
|
-
#
|
659
|
+
# RubyGems versions 1.3.6 and 1.3.7
|
581
660
|
class Ancient < Legacy
|
582
661
|
def initialize
|
583
662
|
super
|
@@ -585,7 +664,7 @@ module Bundler
|
|
585
664
|
end
|
586
665
|
end
|
587
666
|
|
588
|
-
#
|
667
|
+
# RubyGems 1.7
|
589
668
|
class Transitional < Legacy
|
590
669
|
def stub_rubygems(specs)
|
591
670
|
stub_source_index(specs)
|
@@ -599,7 +678,7 @@ module Bundler
|
|
599
678
|
end
|
600
679
|
end
|
601
680
|
|
602
|
-
#
|
681
|
+
# RubyGems 1.8.5-1.8.19
|
603
682
|
class Modern < RubygemsIntegration
|
604
683
|
def stub_rubygems(specs)
|
605
684
|
Gem::Specification.all = specs
|
@@ -620,9 +699,9 @@ module Bundler
|
|
620
699
|
end
|
621
700
|
end
|
622
701
|
|
623
|
-
#
|
702
|
+
# RubyGems 1.8.0 to 1.8.4
|
624
703
|
class AlmostModern < Modern
|
625
|
-
#
|
704
|
+
# RubyGems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever
|
626
705
|
# you call Gem::Installer#install with an :install_dir set. We have to
|
627
706
|
# change it back for our sudo mode to work.
|
628
707
|
def preserve_paths
|
@@ -633,9 +712,9 @@ module Bundler
|
|
633
712
|
end
|
634
713
|
end
|
635
714
|
|
636
|
-
#
|
715
|
+
# RubyGems 1.8.20+
|
637
716
|
class MoreModern < Modern
|
638
|
-
#
|
717
|
+
# RubyGems 1.8.20 and adds the skip_validation parameter, so that's
|
639
718
|
# when we start passing it through.
|
640
719
|
def build(spec, skip_validation = false)
|
641
720
|
require "rubygems/builder"
|
@@ -643,7 +722,7 @@ module Bundler
|
|
643
722
|
end
|
644
723
|
end
|
645
724
|
|
646
|
-
#
|
725
|
+
# RubyGems 2.0
|
647
726
|
class Future < RubygemsIntegration
|
648
727
|
def stub_rubygems(specs)
|
649
728
|
Gem::Specification.all = specs
|
@@ -651,6 +730,10 @@ module Bundler
|
|
651
730
|
Gem.post_reset do
|
652
731
|
Gem::Specification.all = specs
|
653
732
|
end
|
733
|
+
|
734
|
+
redefine_method((class << Gem; self; end), :finish_resolve) do |*|
|
735
|
+
[]
|
736
|
+
end
|
654
737
|
end
|
655
738
|
|
656
739
|
def all_specs
|
@@ -685,7 +768,9 @@ module Bundler
|
|
685
768
|
uri = Bundler.settings.mirror_for(uri)
|
686
769
|
fetcher = gem_remote_fetcher
|
687
770
|
fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
|
688
|
-
|
771
|
+
Bundler::Retry.new("download gem from #{uri}").attempts do
|
772
|
+
fetcher.download(spec, uri, path)
|
773
|
+
end
|
689
774
|
end
|
690
775
|
|
691
776
|
def gem_remote_fetcher
|
@@ -710,6 +795,14 @@ module Bundler
|
|
710
795
|
def repository_subdirectories
|
711
796
|
Gem::REPOSITORY_SUBDIRECTORIES
|
712
797
|
end
|
798
|
+
|
799
|
+
def install_with_build_args(args)
|
800
|
+
yield
|
801
|
+
end
|
802
|
+
|
803
|
+
def path_separator
|
804
|
+
Gem.path_separator
|
805
|
+
end
|
713
806
|
end
|
714
807
|
|
715
808
|
# RubyGems 2.1.0
|
@@ -727,7 +820,13 @@ module Bundler
|
|
727
820
|
end
|
728
821
|
|
729
822
|
def backport_ext_builder_monitor
|
730
|
-
|
823
|
+
# So we can avoid requiring "rubygems/ext" in its entirety
|
824
|
+
Gem.module_eval <<-RB, __FILE__, __LINE__ + 1
|
825
|
+
module Ext
|
826
|
+
end
|
827
|
+
RB
|
828
|
+
|
829
|
+
require "rubygems/ext/builder"
|
731
830
|
|
732
831
|
Gem::Ext::Builder.class_eval do
|
733
832
|
unless const_defined?(:CHDIR_MONITOR)
|
@@ -750,6 +849,30 @@ module Bundler
|
|
750
849
|
end.map(&:to_spec)
|
751
850
|
end
|
752
851
|
end
|
852
|
+
|
853
|
+
def use_gemdeps(gemfile)
|
854
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
|
855
|
+
require "bundler/gemdeps"
|
856
|
+
runtime = Bundler.setup
|
857
|
+
Bundler.ui = nil
|
858
|
+
activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
|
859
|
+
[Gemdeps.new(runtime), activated_spec_names]
|
860
|
+
end
|
861
|
+
|
862
|
+
if provides?(">= 2.5.2")
|
863
|
+
# RubyGems-generated binstubs call Kernel#gem
|
864
|
+
def binstubs_call_gem?
|
865
|
+
false
|
866
|
+
end
|
867
|
+
|
868
|
+
# only 2.5.2+ has all of the stub methods we want to use, and since this
|
869
|
+
# is a performance optimization _only_,
|
870
|
+
# we'll restrict ourselves to the most
|
871
|
+
# recent RG versions instead of all versions that have stubs
|
872
|
+
def stubs_provide_full_functionality?
|
873
|
+
true
|
874
|
+
end
|
875
|
+
end
|
753
876
|
end
|
754
877
|
end
|
755
878
|
|
@@ -768,7 +891,7 @@ module Bundler
|
|
768
891
|
RubygemsIntegration::Transitional.new
|
769
892
|
elsif RubygemsIntegration.provides?(">= 1.4.0")
|
770
893
|
RubygemsIntegration::Legacy.new
|
771
|
-
else #
|
894
|
+
else # RubyGems 1.3.6 and 1.3.7
|
772
895
|
RubygemsIntegration::Ancient.new
|
773
896
|
end
|
774
897
|
end
|