bundler 1.11.1 → 2.2.6
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 +2125 -840
- data/LICENSE.md +18 -19
- data/README.md +33 -11
- data/bundler.gemspec +34 -21
- data/exe/bundle +36 -6
- data/exe/bundler +2 -18
- data/lib/bundler.rb +435 -160
- data/lib/bundler/build_metadata.rb +45 -0
- data/lib/bundler/capistrano.rb +9 -3
- data/lib/bundler/cli.rb +550 -130
- data/lib/bundler/cli/add.rb +47 -0
- data/lib/bundler/cli/binstubs.rb +26 -10
- data/lib/bundler/cli/cache.rb +25 -17
- data/lib/bundler/cli/check.rb +8 -7
- data/lib/bundler/cli/clean.rb +8 -8
- data/lib/bundler/cli/common.rb +69 -9
- data/lib/bundler/cli/config.rb +170 -76
- data/lib/bundler/cli/console.rb +6 -1
- data/lib/bundler/cli/doctor.rb +140 -0
- data/lib/bundler/cli/exec.rb +63 -21
- data/lib/bundler/cli/fund.rb +36 -0
- data/lib/bundler/cli/gem.rb +158 -42
- data/lib/bundler/cli/info.rb +73 -0
- data/lib/bundler/cli/init.rb +22 -7
- data/lib/bundler/cli/inject.rb +38 -10
- data/lib/bundler/cli/install.rb +139 -104
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +60 -0
- data/lib/bundler/cli/lock.rb +27 -5
- data/lib/bundler/cli/open.rb +13 -5
- data/lib/bundler/cli/outdated.rb +251 -46
- data/lib/bundler/cli/platform.rb +6 -2
- data/lib/bundler/cli/plugin.rb +41 -0
- data/lib/bundler/cli/pristine.rb +52 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +5 -4
- data/lib/bundler/cli/update.rb +67 -26
- data/lib/bundler/cli/viz.rb +11 -6
- data/lib/bundler/compact_index_client.rb +125 -0
- data/lib/bundler/compact_index_client/cache.rb +110 -0
- data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
- data/lib/bundler/compact_index_client/updater.rb +104 -0
- data/lib/bundler/constants.rb +2 -0
- data/lib/bundler/current_ruby.rb +51 -174
- data/lib/bundler/definition.rb +533 -216
- data/lib/bundler/dep_proxy.rb +18 -8
- data/lib/bundler/dependency.rb +39 -12
- data/lib/bundler/deployment.rb +7 -0
- data/lib/bundler/deprecate.rb +31 -2
- data/lib/bundler/dsl.rb +188 -91
- data/lib/bundler/endpoint_specification.rb +51 -10
- data/lib/bundler/env.rb +116 -48
- data/lib/bundler/environment_preserver.rb +82 -0
- data/lib/bundler/errors.rb +108 -31
- data/lib/bundler/feature_flag.rb +60 -0
- data/lib/bundler/fetcher.rb +81 -52
- data/lib/bundler/fetcher/base.rb +15 -3
- data/lib/bundler/fetcher/compact_index.rb +140 -0
- data/lib/bundler/fetcher/dependency.rb +36 -42
- data/lib/bundler/fetcher/downloader.rb +39 -12
- data/lib/bundler/fetcher/index.rb +34 -9
- data/lib/bundler/friendly_errors.rb +132 -88
- data/lib/bundler/gem_helper.rb +92 -50
- data/lib/bundler/gem_helpers.rb +90 -5
- data/lib/bundler/gem_tasks.rb +3 -1
- data/lib/bundler/gem_version_promoter.rb +190 -0
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +20 -41
- data/lib/bundler/index.rb +74 -57
- data/lib/bundler/injector.rb +242 -31
- data/lib/bundler/inline.rb +49 -23
- data/lib/bundler/installer.rb +190 -74
- data/lib/bundler/installer/gem_installer.rb +33 -20
- data/lib/bundler/installer/parallel_installer.rb +201 -97
- data/lib/bundler/installer/standalone.rb +10 -6
- data/lib/bundler/lazy_specification.rb +74 -10
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +126 -74
- data/lib/bundler/{ssl_certs → man}/.document +0 -0
- data/lib/bundler/man/bundle-add.1 +66 -0
- data/lib/bundler/man/bundle-add.1.ronn +46 -0
- data/lib/bundler/man/bundle-binstubs.1 +42 -0
- data/lib/bundler/man/bundle-binstubs.1.ronn +41 -0
- data/lib/bundler/man/bundle-cache.1 +55 -0
- data/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +22 -16
- data/lib/bundler/man/bundle-check.1 +31 -0
- data/lib/bundler/man/bundle-check.1.ronn +26 -0
- data/lib/bundler/man/bundle-clean.1 +24 -0
- data/lib/bundler/man/bundle-clean.1.ronn +18 -0
- data/lib/bundler/man/bundle-config.1 +488 -0
- data/lib/bundler/man/bundle-config.1.ronn +388 -0
- data/lib/bundler/man/bundle-doctor.1 +44 -0
- data/lib/bundler/man/bundle-doctor.1.ronn +33 -0
- data/lib/bundler/man/bundle-exec.1 +165 -0
- data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +20 -4
- data/lib/bundler/man/bundle-gem.1 +102 -0
- data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +37 -13
- data/lib/bundler/man/bundle-info.1 +20 -0
- data/lib/bundler/man/bundle-info.1.ronn +17 -0
- data/lib/bundler/man/bundle-init.1 +25 -0
- data/lib/bundler/man/bundle-init.1.ronn +29 -0
- data/lib/bundler/man/bundle-inject.1 +33 -0
- data/lib/bundler/man/bundle-inject.1.ronn +22 -0
- data/lib/bundler/man/bundle-install.1 +338 -0
- data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +82 -76
- data/lib/bundler/man/bundle-list.1 +50 -0
- data/lib/bundler/man/bundle-list.1.ronn +33 -0
- data/lib/bundler/man/bundle-lock.1 +84 -0
- data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +47 -0
- data/lib/bundler/man/bundle-open.1 +32 -0
- data/lib/bundler/man/bundle-open.1.ronn +19 -0
- data/lib/bundler/man/bundle-outdated.1 +155 -0
- data/lib/bundler/man/bundle-outdated.1.ronn +111 -0
- data/lib/bundler/man/bundle-platform.1 +61 -0
- data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +1 -1
- data/lib/bundler/man/bundle-pristine.1 +34 -0
- data/lib/bundler/man/bundle-pristine.1.ronn +34 -0
- data/lib/bundler/man/bundle-remove.1 +31 -0
- data/lib/bundler/man/bundle-remove.1.ronn +23 -0
- data/lib/bundler/man/bundle-show.1 +23 -0
- data/lib/bundler/man/bundle-show.1.ronn +21 -0
- data/lib/bundler/man/bundle-update.1 +394 -0
- data/lib/bundler/man/bundle-update.1.ronn +350 -0
- data/lib/bundler/man/bundle-viz.1 +39 -0
- data/lib/bundler/man/bundle-viz.1.ronn +30 -0
- data/lib/bundler/man/bundle.1 +136 -0
- data/lib/bundler/man/bundle.1.ronn +111 -0
- data/lib/bundler/man/gemfile.5 +686 -0
- data/{man → lib/bundler/man}/gemfile.5.ronn +117 -95
- data/lib/bundler/man/index.txt +25 -0
- data/lib/bundler/match_platform.rb +15 -4
- data/lib/bundler/mirror.rb +223 -0
- data/lib/bundler/plugin.rb +330 -0
- data/lib/bundler/plugin/api.rb +81 -0
- data/lib/bundler/plugin/api/source.rb +304 -0
- data/lib/bundler/plugin/dsl.rb +53 -0
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +182 -0
- data/lib/bundler/plugin/installer.rb +109 -0
- data/lib/bundler/plugin/installer/git.rb +38 -0
- data/lib/bundler/plugin/installer/rubygems.rb +27 -0
- data/lib/bundler/plugin/source_list.rb +27 -0
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +2 -6
- data/lib/bundler/remote_specification.rb +42 -9
- data/lib/bundler/resolver.rb +312 -225
- data/lib/bundler/resolver/spec_group.rb +122 -0
- data/lib/bundler/retry.rb +11 -5
- data/lib/bundler/ruby_dsl.rb +9 -2
- data/lib/bundler/ruby_version.rb +84 -61
- data/lib/bundler/rubygems_ext.rb +92 -53
- data/lib/bundler/rubygems_gem_installer.rb +84 -0
- data/lib/bundler/rubygems_integration.rb +320 -395
- data/lib/bundler/runtime.rb +87 -75
- data/lib/bundler/settings.rb +297 -119
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +13 -12
- data/lib/bundler/shared_helpers.rb +234 -53
- data/lib/bundler/similarity_detector.rb +5 -3
- data/lib/bundler/source.rb +63 -4
- data/lib/bundler/source/gemspec.rb +18 -0
- data/lib/bundler/source/git.rb +97 -50
- data/lib/bundler/source/git/git_proxy.rb +138 -65
- data/lib/bundler/source/metadata.rb +67 -0
- data/lib/bundler/source/path.rb +83 -47
- data/lib/bundler/source/path/installer.rb +42 -11
- data/lib/bundler/source/rubygems.rb +231 -116
- data/lib/bundler/source/rubygems/remote.rb +30 -1
- data/lib/bundler/source_list.rb +103 -21
- data/lib/bundler/spec_set.rb +96 -51
- data/lib/bundler/stub_specification.rb +87 -4
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +14 -1
- data/lib/bundler/templates/Executable.bundler +114 -0
- data/lib/bundler/templates/Executable.standalone +6 -4
- data/lib/bundler/templates/Gemfile +4 -1
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +79 -44
- data/lib/bundler/templates/newgem/Gemfile.tt +18 -2
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
- data/lib/bundler/templates/newgem/README.md.tt +16 -10
- data/lib/bundler/templates/newgem/Rakefile.tt +22 -8
- data/lib/bundler/templates/newgem/bin/console.tt +2 -1
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +18 -0
- data/lib/bundler/templates/newgem/gitignore.tt +5 -1
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -6
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +6 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -28
- data/lib/bundler/templates/newgem/rspec.tt +1 -0
- data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +4 -4
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +15 -2
- data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +3 -1
- data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
- data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
- data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
- data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
- data/lib/bundler/ui.rb +5 -3
- data/lib/bundler/ui/rg_proxy.rb +3 -1
- data/lib/bundler/ui/shell.rb +54 -21
- data/lib/bundler/ui/silent.rb +26 -1
- data/lib/bundler/uri_credentials_filter.rb +43 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1764 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +11 -5
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +113 -134
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
- 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 +61 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +158 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +82 -8
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +4 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +2 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +6 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +555 -150
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +6 -3
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +19 -12
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +310 -467
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +58 -25
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +50 -33
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +5 -3
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +9 -19
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +79 -22
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +33 -20
- data/lib/bundler/vendor/thor/lib/thor/base.rb +110 -67
- data/lib/bundler/vendor/thor/lib/thor/command.rb +33 -24
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
- data/lib/bundler/vendor/thor/lib/thor/error.rb +81 -3
- data/lib/bundler/vendor/thor/lib/thor/group.rb +16 -16
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +5 -5
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +18 -18
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +60 -26
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +31 -13
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +42 -39
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +5 -5
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +109 -39
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +7 -3
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +5 -5
- data/lib/bundler/vendor/thor/lib/thor/util.rb +26 -9
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
- data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
- data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
- data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
- data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
- data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
- data/lib/bundler/vendored_fileutils.rb +4 -0
- data/lib/bundler/vendored_molinillo.rb +3 -1
- data/lib/bundler/vendored_persistent.rb +45 -9
- data/lib/bundler/vendored_thor.rb +8 -3
- data/lib/bundler/vendored_tmpdir.rb +4 -0
- data/lib/bundler/vendored_uri.rb +4 -0
- data/lib/bundler/version.rb +7 -4
- data/lib/bundler/version_ranges.rb +122 -0
- data/lib/bundler/vlad.rb +8 -2
- data/lib/bundler/worker.rb +38 -6
- data/lib/bundler/yaml_serializer.rb +89 -0
- metadata +164 -158
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -105
- data/.rubocop_todo.yml +0 -120
- data/.travis.yml +0 -97
- data/CODE_OF_CONDUCT.md +0 -42
- data/CONTRIBUTING.md +0 -32
- data/DEVELOPMENT.md +0 -118
- data/ISSUES.md +0 -96
- data/Rakefile +0 -309
- data/bin/rake +0 -14
- data/bin/rspec +0 -10
- data/bin/rubocop +0 -11
- data/exe/bundle_ruby +0 -60
- data/lib/bundler/cli/package.rb +0 -45
- data/lib/bundler/environment.rb +0 -41
- data/lib/bundler/gem_path_manipulation.rb +0 -8
- data/lib/bundler/gem_remote_fetcher.rb +0 -41
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot.pem +0 -32
- data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
- data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
- data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +0 -20
- data/lib/bundler/ssl_certs/certificate_manager.rb +0 -64
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
- data/lib/bundler/vendor/net/http/faster.rb +0 -26
- data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +0 -128
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -10
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -98
- data/man/bundle-config.ronn +0 -187
- data/man/bundle-update.ronn +0 -188
- data/man/bundle.ronn +0 -98
- data/man/index.txt +0 -8
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rubygems/installer"
|
2
4
|
|
3
5
|
module Bundler
|
@@ -5,5 +7,87 @@ module Bundler
|
|
5
7
|
def check_executable_overwrite(filename)
|
6
8
|
# Bundler needs to install gems regardless of binstub overwriting
|
7
9
|
end
|
10
|
+
|
11
|
+
def pre_install_checks
|
12
|
+
super && validate_bundler_checksum(options[:bundler_expected_checksum])
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_extensions
|
16
|
+
extension_cache_path = options[:bundler_extension_cache_path]
|
17
|
+
return super unless extension_cache_path && extension_dir = spec.extension_dir
|
18
|
+
|
19
|
+
extension_dir = Pathname.new(extension_dir)
|
20
|
+
build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
|
21
|
+
if build_complete && !options[:force]
|
22
|
+
SharedHelpers.filesystem_access(extension_dir.parent, &:mkpath)
|
23
|
+
SharedHelpers.filesystem_access(extension_cache_path) do
|
24
|
+
FileUtils.cp_r extension_cache_path, spec.extension_dir
|
25
|
+
end
|
26
|
+
else
|
27
|
+
super
|
28
|
+
if extension_dir.directory? # not made for gems without extensions
|
29
|
+
SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
|
30
|
+
SharedHelpers.filesystem_access(extension_cache_path) do
|
31
|
+
FileUtils.cp_r extension_dir, extension_cache_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def validate_bundler_checksum(checksum)
|
40
|
+
return true if Bundler.settings[:disable_checksum_validation]
|
41
|
+
return true unless checksum
|
42
|
+
return true unless source = @package.instance_variable_get(:@gem)
|
43
|
+
return true unless source.respond_to?(:with_read_io)
|
44
|
+
digest = source.with_read_io do |io|
|
45
|
+
digest = SharedHelpers.digest(:SHA256).new
|
46
|
+
digest << io.read(16_384) until io.eof?
|
47
|
+
io.rewind
|
48
|
+
send(checksum_type(checksum), digest)
|
49
|
+
end
|
50
|
+
unless digest == checksum
|
51
|
+
raise SecurityError, <<-MESSAGE
|
52
|
+
Bundler cannot continue installing #{spec.name} (#{spec.version}).
|
53
|
+
The checksum for the downloaded `#{spec.full_name}.gem` does not match \
|
54
|
+
the checksum given by the server. This means the contents of the downloaded \
|
55
|
+
gem is different from what was uploaded to the server, and could be a potential security issue.
|
56
|
+
|
57
|
+
To resolve this issue:
|
58
|
+
1. delete the downloaded gem located at: `#{spec.gem_dir}/#{spec.full_name}.gem`
|
59
|
+
2. run `bundle install`
|
60
|
+
|
61
|
+
If you wish to continue installing the downloaded gem, and are certain it does not pose a \
|
62
|
+
security issue despite the mismatching checksum, do the following:
|
63
|
+
1. run `bundle config set --local disable_checksum_validation true` to turn off checksum verification
|
64
|
+
2. run `bundle install`
|
65
|
+
|
66
|
+
(More info: The expected SHA256 checksum was #{checksum.inspect}, but the \
|
67
|
+
checksum for the downloaded gem was #{digest.inspect}.)
|
68
|
+
MESSAGE
|
69
|
+
end
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
73
|
+
def checksum_type(checksum)
|
74
|
+
case checksum.length
|
75
|
+
when 64 then :hexdigest!
|
76
|
+
when 44 then :base64digest!
|
77
|
+
else raise InstallError, "The given checksum for #{spec.full_name} (#{checksum.inspect}) is not a valid SHA256 hexdigest nor base64digest"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def hexdigest!(digest)
|
82
|
+
digest.hexdigest!
|
83
|
+
end
|
84
|
+
|
85
|
+
def base64digest!(digest)
|
86
|
+
if digest.respond_to?(:base64digest!)
|
87
|
+
digest.base64digest!
|
88
|
+
else
|
89
|
+
[digest.digest!].pack("m0")
|
90
|
+
end
|
91
|
+
end
|
8
92
|
end
|
9
93
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "rubygems
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubygems" unless defined?(Gem)
|
4
4
|
|
5
5
|
module Bundler
|
6
6
|
class RubygemsIntegration
|
7
7
|
if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
|
8
8
|
EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
|
9
9
|
else
|
10
|
+
require "monitor"
|
11
|
+
|
10
12
|
EXT_LOCK = Monitor.new
|
11
13
|
end
|
12
14
|
|
@@ -18,6 +20,11 @@ module Bundler
|
|
18
20
|
Gem::Requirement.new(req_str).satisfied_by?(version)
|
19
21
|
end
|
20
22
|
|
23
|
+
def initialize
|
24
|
+
@replaced_methods = {}
|
25
|
+
backport_ext_builder_monitor
|
26
|
+
end
|
27
|
+
|
21
28
|
def version
|
22
29
|
self.class.version
|
23
30
|
end
|
@@ -38,6 +45,18 @@ module Bundler
|
|
38
45
|
Gem.loaded_specs[name]
|
39
46
|
end
|
40
47
|
|
48
|
+
def add_to_load_path(paths)
|
49
|
+
return Gem.add_to_load_path(*paths) if Gem.respond_to?(:add_to_load_path)
|
50
|
+
|
51
|
+
if insert_index = Gem.load_path_insert_index
|
52
|
+
# Gem directories must come after -I and ENV['RUBYLIB']
|
53
|
+
$LOAD_PATH.insert(insert_index, *paths)
|
54
|
+
else
|
55
|
+
# We are probably testing in core, -I and RUBYLIB don't apply
|
56
|
+
$LOAD_PATH.unshift(*paths)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
41
60
|
def mark_loaded(spec)
|
42
61
|
if spec.respond_to?(:activated=)
|
43
62
|
current = Gem.loaded_specs[spec.name]
|
@@ -49,22 +68,52 @@ module Bundler
|
|
49
68
|
|
50
69
|
def validate(spec)
|
51
70
|
Bundler.ui.silence { spec.validate(false) }
|
71
|
+
rescue Gem::InvalidSpecificationException => e
|
72
|
+
error_message = "The gemspec at #{spec.loaded_from} is not valid. Please fix this gemspec.\n" \
|
73
|
+
"The validation error was '#{e.message}'\n"
|
74
|
+
raise Gem::InvalidSpecificationException.new(error_message)
|
52
75
|
rescue Errno::ENOENT
|
53
76
|
nil
|
54
77
|
end
|
55
78
|
|
56
|
-
def
|
57
|
-
|
79
|
+
def set_installed_by_version(spec, installed_by_version = Gem::VERSION)
|
80
|
+
return unless spec.respond_to?(:installed_by_version=)
|
81
|
+
spec.installed_by_version = Gem::Version.create(installed_by_version)
|
82
|
+
end
|
83
|
+
|
84
|
+
def spec_missing_extensions?(spec, default = true)
|
85
|
+
return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
|
86
|
+
|
87
|
+
return false if spec_default_gem?(spec)
|
88
|
+
return false if spec.extensions.empty?
|
89
|
+
|
90
|
+
default
|
91
|
+
end
|
92
|
+
|
93
|
+
def spec_default_gem?(spec)
|
94
|
+
spec.respond_to?(:default_gem?) && spec.default_gem?
|
95
|
+
end
|
96
|
+
|
97
|
+
def spec_matches_for_glob(spec, glob)
|
98
|
+
return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
|
99
|
+
|
100
|
+
spec.load_paths.map do |lp|
|
101
|
+
Dir["#{lp}/#{glob}#{suffix_pattern}"]
|
102
|
+
end.flatten(1)
|
103
|
+
end
|
104
|
+
|
105
|
+
def stub_set_spec(stub, spec)
|
106
|
+
stub.instance_variable_set(:@spec, spec)
|
58
107
|
end
|
59
108
|
|
60
|
-
def
|
61
|
-
|
109
|
+
def path(obj)
|
110
|
+
obj.to_s
|
62
111
|
end
|
63
112
|
|
64
113
|
def configuration
|
65
|
-
|
114
|
+
require_relative "psyched_yaml"
|
66
115
|
Gem.configuration
|
67
|
-
rescue Gem::SystemExitException => e
|
116
|
+
rescue Gem::SystemExitException, LoadError => e
|
68
117
|
Bundler.ui.error "#{e.class}: #{e.message}"
|
69
118
|
Bundler.ui.trace e
|
70
119
|
raise
|
@@ -82,7 +131,17 @@ module Bundler
|
|
82
131
|
end
|
83
132
|
|
84
133
|
def inflate(obj)
|
85
|
-
Gem.inflate(obj)
|
134
|
+
Gem::Util.inflate(obj)
|
135
|
+
end
|
136
|
+
|
137
|
+
def correct_for_windows_path(path)
|
138
|
+
if Gem::Util.respond_to?(:correct_for_windows_path)
|
139
|
+
Gem::Util.correct_for_windows_path(path)
|
140
|
+
elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
|
141
|
+
path[1..-1]
|
142
|
+
else
|
143
|
+
path
|
144
|
+
end
|
86
145
|
end
|
87
146
|
|
88
147
|
def sources=(val)
|
@@ -114,6 +173,18 @@ module Bundler
|
|
114
173
|
Gem.path
|
115
174
|
end
|
116
175
|
|
176
|
+
def reset
|
177
|
+
Gem::Specification.reset
|
178
|
+
end
|
179
|
+
|
180
|
+
def post_reset_hooks
|
181
|
+
Gem.post_reset_hooks
|
182
|
+
end
|
183
|
+
|
184
|
+
def suffix_pattern
|
185
|
+
Gem.suffix_pattern
|
186
|
+
end
|
187
|
+
|
117
188
|
def gem_cache
|
118
189
|
gem_path.map {|p| File.expand_path("cache", p) }
|
119
190
|
end
|
@@ -121,7 +192,7 @@ module Bundler
|
|
121
192
|
def spec_cache_dirs
|
122
193
|
@spec_cache_dirs ||= begin
|
123
194
|
dirs = gem_path.map {|dir| File.join(dir, "specifications") }
|
124
|
-
dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in
|
195
|
+
dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in RubyGems 2.0.3 or earlier
|
125
196
|
dirs.uniq.select {|dir| File.directory? dir }
|
126
197
|
end
|
127
198
|
end
|
@@ -130,14 +201,6 @@ module Bundler
|
|
130
201
|
Gem::MARSHAL_SPEC_DIR
|
131
202
|
end
|
132
203
|
|
133
|
-
def config_map
|
134
|
-
Gem::ConfigMap
|
135
|
-
end
|
136
|
-
|
137
|
-
def repository_subdirectories
|
138
|
-
%w(cache doc gems specifications)
|
139
|
-
end
|
140
|
-
|
141
204
|
def clear_paths
|
142
205
|
Gem.clear_paths
|
143
206
|
end
|
@@ -146,59 +209,29 @@ module Bundler
|
|
146
209
|
Gem.bin_path(gem, bin, ver)
|
147
210
|
end
|
148
211
|
|
149
|
-
def preserve_paths
|
150
|
-
# this is a no-op outside of Rubygems 1.8
|
151
|
-
yield
|
152
|
-
end
|
153
|
-
|
154
212
|
def loaded_gem_paths
|
155
|
-
|
156
|
-
|
157
|
-
if Gem::Specification.method_defined? :full_require_paths
|
158
|
-
loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
|
159
|
-
loaded_gem_paths.flatten
|
160
|
-
else
|
161
|
-
$LOAD_PATH.select do |p|
|
162
|
-
Bundler.rubygems.gem_path.any? {|gp| p =~ /^#{Regexp.escape(gp)}/ }
|
163
|
-
end
|
164
|
-
end
|
213
|
+
loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
|
214
|
+
loaded_gem_paths.flatten
|
165
215
|
end
|
166
216
|
|
167
|
-
def
|
168
|
-
Gem
|
217
|
+
def load_plugins
|
218
|
+
Gem.load_plugins if Gem.respond_to?(:load_plugins)
|
169
219
|
end
|
170
220
|
|
171
|
-
def
|
172
|
-
|
221
|
+
def load_plugin_files(files)
|
222
|
+
Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files)
|
173
223
|
end
|
174
224
|
|
175
|
-
def
|
176
|
-
|
177
|
-
specs.each { yield } if block_given?
|
178
|
-
specs
|
225
|
+
def load_env_plugins
|
226
|
+
Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
|
179
227
|
end
|
180
228
|
|
181
|
-
def
|
182
|
-
|
183
|
-
rescue Gem::RemoteFetcher::FetchError
|
184
|
-
[] # if we can't download them, there aren't any
|
229
|
+
def ui=(obj)
|
230
|
+
Gem::DefaultUserInteraction.ui = obj
|
185
231
|
end
|
186
232
|
|
187
|
-
|
188
|
-
|
189
|
-
# Maybe the newer implementation will work on older Rubygems?
|
190
|
-
# It seems difficult to keep this implementation and still send the header.
|
191
|
-
def fetch_all_remote_specs(remote)
|
192
|
-
old_sources = Bundler.rubygems.sources
|
193
|
-
Bundler.rubygems.sources = [remote.uri.to_s]
|
194
|
-
# Fetch all specs, minus prerelease specs
|
195
|
-
spec_list = fetch_specs(true, false)
|
196
|
-
# Then fetch the prerelease specs
|
197
|
-
fetch_prerelease_specs.each {|k, v| spec_list[k] += v }
|
198
|
-
|
199
|
-
spec_list
|
200
|
-
ensure
|
201
|
-
Bundler.rubygems.sources = old_sources
|
233
|
+
def ext_lock
|
234
|
+
EXT_LOCK
|
202
235
|
end
|
203
236
|
|
204
237
|
def with_build_args(args)
|
@@ -213,17 +246,11 @@ module Bundler
|
|
213
246
|
end
|
214
247
|
end
|
215
248
|
|
216
|
-
def gem_from_path(path, policy = nil)
|
217
|
-
require "rubygems/format"
|
218
|
-
Gem::Format.from_file_by_path(path, policy)
|
219
|
-
end
|
220
|
-
|
221
249
|
def spec_from_gem(path, policy = nil)
|
222
250
|
require "rubygems/security"
|
251
|
+
require_relative "psyched_yaml"
|
223
252
|
gem_from_path(path, security_policies[policy]).spec
|
224
|
-
rescue Gem::
|
225
|
-
raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
|
226
|
-
rescue Exception, Gem::Exception, Gem::Security::Exception => e
|
253
|
+
rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
|
227
254
|
if e.is_a?(Gem::Security::Exception) ||
|
228
255
|
e.message =~ /unknown trust policy|unsigned gem/i ||
|
229
256
|
e.message =~ /couldn't verify (meta)?data signature/i
|
@@ -235,23 +262,12 @@ module Bundler
|
|
235
262
|
end
|
236
263
|
end
|
237
264
|
|
238
|
-
def build(spec, skip_validation = false)
|
239
|
-
require "rubygems/builder"
|
240
|
-
Gem::Builder.new(spec).build
|
241
|
-
end
|
242
|
-
|
243
265
|
def build_gem(gem_dir, spec)
|
244
266
|
build(spec)
|
245
267
|
end
|
246
268
|
|
247
|
-
def download_gem(spec, uri, path)
|
248
|
-
uri = Bundler.settings.mirror_for(uri)
|
249
|
-
fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy])
|
250
|
-
fetcher.download(spec, uri, path)
|
251
|
-
end
|
252
|
-
|
253
269
|
def security_policy_keys
|
254
|
-
%w
|
270
|
+
%w[High Medium Low AlmostNo No].map {|level| "#{level}Security" }
|
255
271
|
end
|
256
272
|
|
257
273
|
def security_policies
|
@@ -265,424 +281,333 @@ module Bundler
|
|
265
281
|
|
266
282
|
def reverse_rubygems_kernel_mixin
|
267
283
|
# Disable rubygems' gem activation system
|
268
|
-
::Kernel
|
269
|
-
|
270
|
-
|
271
|
-
|
284
|
+
kernel = (class << ::Kernel; self; end)
|
285
|
+
[kernel, ::Kernel].each do |k|
|
286
|
+
if k.private_method_defined?(:gem_original_require)
|
287
|
+
redefine_method(k, :require, k.instance_method(:gem_original_require))
|
272
288
|
end
|
273
|
-
|
274
|
-
undef gem
|
275
289
|
end
|
276
290
|
end
|
277
291
|
|
278
|
-
def replace_gem(specs)
|
292
|
+
def replace_gem(specs, specs_by_name)
|
279
293
|
reverse_rubygems_kernel_mixin
|
280
294
|
|
281
|
-
executables =
|
295
|
+
executables = nil
|
282
296
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
297
|
+
kernel = (class << ::Kernel; self; end)
|
298
|
+
[kernel, ::Kernel].each do |kernel_class|
|
299
|
+
redefine_method(kernel_class, :gem) do |dep, *reqs|
|
300
|
+
if executables && executables.include?(File.basename(caller.first.split(":").first))
|
301
|
+
break
|
302
|
+
end
|
288
303
|
|
289
|
-
|
290
|
-
dep = Gem::Dependency.new(dep, reqs)
|
291
|
-
end
|
304
|
+
reqs.pop if reqs.last.is_a?(Hash)
|
292
305
|
|
293
|
-
|
306
|
+
unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
|
307
|
+
dep = Gem::Dependency.new(dep, reqs)
|
308
|
+
end
|
294
309
|
|
295
|
-
|
310
|
+
if spec = specs_by_name[dep.name]
|
311
|
+
return true if dep.matches_spec?(spec)
|
312
|
+
end
|
296
313
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
314
|
+
message = if spec.nil?
|
315
|
+
target_file = begin
|
316
|
+
Bundler.default_gemfile.basename
|
317
|
+
rescue GemfileNotFound
|
318
|
+
"inline Gemfile"
|
319
|
+
end
|
320
|
+
"#{dep.name} is not part of the bundle." \
|
321
|
+
" Add it to your #{target_file}."
|
301
322
|
else
|
302
|
-
|
323
|
+
"can't activate #{dep}, already activated #{spec.full_name}. " \
|
324
|
+
"Make sure all dependencies are added to Gemfile."
|
303
325
|
end
|
304
|
-
|
305
|
-
|
306
|
-
e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
|
307
|
-
"Make sure all dependencies are added to Gemfile."
|
326
|
+
|
327
|
+
e = Gem::LoadError.new(message)
|
308
328
|
e.name = dep.name
|
309
329
|
if e.respond_to?(:requirement=)
|
310
330
|
e.requirement = dep.requirement
|
311
|
-
|
331
|
+
elsif e.respond_to?(:version_requirement=)
|
312
332
|
e.version_requirement = dep.requirement
|
313
333
|
end
|
314
334
|
raise e
|
315
335
|
end
|
316
336
|
|
317
|
-
|
318
|
-
|
319
|
-
end
|
320
|
-
|
321
|
-
def stub_source_index(specs)
|
322
|
-
Gem::SourceIndex.send(:alias_method, :old_initialize, :initialize)
|
323
|
-
redefine_method(Gem::SourceIndex, :initialize) do |*args|
|
324
|
-
@gems = {}
|
325
|
-
# You're looking at this thinking: Oh! This is how I make those
|
326
|
-
# rubygems deprecations go away!
|
327
|
-
#
|
328
|
-
# You'd be correct BUT using of this method in production code
|
329
|
-
# must be approved by the rubygems team itself!
|
330
|
-
#
|
331
|
-
# This is your warning. If you use this and don't have approval
|
332
|
-
# we can't protect you.
|
333
|
-
#
|
334
|
-
Deprecate.skip_during do
|
335
|
-
self.spec_dirs = *args
|
336
|
-
add_specs(*specs)
|
337
|
-
end
|
337
|
+
# backwards compatibility shim, see https://github.com/rubygems/bundler/issues/5102
|
338
|
+
kernel_class.send(:public, :gem) if Bundler.feature_flag.setup_makes_kernel_gem_public?
|
338
339
|
end
|
339
340
|
end
|
340
341
|
|
341
342
|
# Used to make bin stubs that are not created by bundler work
|
342
343
|
# under bundler. The new Gem.bin_path only considers gems in
|
343
344
|
# +specs+
|
344
|
-
def replace_bin_path(
|
345
|
+
def replace_bin_path(specs_by_name)
|
345
346
|
gem_class = (class << Gem; self; end)
|
346
|
-
redefine_method(gem_class, :bin_path) do |name, *args|
|
347
|
-
exec_name = args.first
|
348
347
|
|
349
|
-
|
348
|
+
redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
|
349
|
+
exec_name = args.first
|
350
|
+
raise ArgumentError, "you must supply exec_name" unless exec_name
|
350
351
|
|
351
|
-
|
352
|
+
spec_with_name = specs_by_name[gem_name]
|
353
|
+
matching_specs_by_exec_name = specs_by_name.values.select {|s| s.executables.include?(exec_name) }
|
354
|
+
spec = matching_specs_by_exec_name.delete(spec_with_name)
|
352
355
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
"This is deprecated, in future versions you may need to `bundle binstub #{name}` " \
|
359
|
-
"to work around a system/bundle conflict."
|
356
|
+
unless spec || !matching_specs_by_exec_name.empty?
|
357
|
+
message = "can't find executable #{exec_name} for gem #{gem_name}"
|
358
|
+
if spec_with_name.nil?
|
359
|
+
message += ". #{gem_name} is not currently included in the bundle, " \
|
360
|
+
"perhaps you meant to add it to your #{Bundler.default_gemfile.basename}?"
|
360
361
|
end
|
361
|
-
|
362
|
-
spec = specs.find {|s| s.name == name }
|
363
|
-
raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name = spec.default_executable
|
362
|
+
raise Gem::Exception, message
|
364
363
|
end
|
365
364
|
|
365
|
+
unless spec
|
366
|
+
spec = matching_specs_by_exec_name.shift
|
367
|
+
warn \
|
368
|
+
"Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \
|
369
|
+
"You should run `bundle binstub #{gem_name}` " \
|
370
|
+
"to work around a system/bundle conflict."
|
371
|
+
end
|
372
|
+
|
373
|
+
unless matching_specs_by_exec_name.empty?
|
374
|
+
conflicting_names = matching_specs_by_exec_name.map(&:name).join(", ")
|
375
|
+
warn \
|
376
|
+
"The `#{exec_name}` executable in the `#{spec.name}` gem is being loaded, but it's also present in other gems (#{conflicting_names}).\n" \
|
377
|
+
"If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
|
378
|
+
"If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
|
379
|
+
end
|
380
|
+
|
381
|
+
spec
|
382
|
+
end
|
383
|
+
|
384
|
+
redefine_method(gem_class, :activate_bin_path) do |name, *args|
|
385
|
+
exec_name = args.first
|
386
|
+
return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
|
387
|
+
|
388
|
+
# Copy of Rubygems activate_bin_path impl
|
389
|
+
requirement = args.last
|
390
|
+
spec = find_spec_for_exe name, exec_name, [requirement]
|
391
|
+
|
366
392
|
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
|
367
393
|
gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
|
368
394
|
File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
|
369
395
|
end
|
370
|
-
end
|
371
396
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
397
|
+
redefine_method(gem_class, :bin_path) do |name, *args|
|
398
|
+
exec_name = args.first
|
399
|
+
return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
|
400
|
+
|
401
|
+
spec = find_spec_for_exe(name, *args)
|
402
|
+
exec_name ||= spec.default_executable
|
403
|
+
|
404
|
+
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
|
405
|
+
gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
|
406
|
+
File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
|
407
|
+
end
|
377
408
|
end
|
378
409
|
|
379
|
-
# Replace or hook into
|
410
|
+
# Replace or hook into RubyGems to provide a bundlerized view
|
380
411
|
# of the world.
|
381
412
|
def replace_entrypoints(specs)
|
382
|
-
|
413
|
+
specs_by_name = add_default_gems_to(specs)
|
383
414
|
|
415
|
+
replace_gem(specs, specs_by_name)
|
384
416
|
stub_rubygems(specs)
|
385
|
-
|
386
|
-
replace_bin_path(specs)
|
387
|
-
replace_refresh
|
417
|
+
replace_bin_path(specs_by_name)
|
388
418
|
|
389
419
|
Gem.clear_paths
|
390
420
|
end
|
391
421
|
|
392
|
-
#
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
/^\d+$/ =~ s ? s.to_i : s
|
398
|
-
end
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
# This backport fixes the marshaling of @segments.
|
403
|
-
def backport_yaml_initialize
|
404
|
-
redefine_method(Gem::Version, :yaml_initialize) do |_, map|
|
405
|
-
@version = map["version"]
|
406
|
-
@segments = nil
|
407
|
-
@hash = nil
|
422
|
+
# Add default gems not already present in specs, and return them as a hash.
|
423
|
+
def add_default_gems_to(specs)
|
424
|
+
specs_by_name = specs.reduce({}) do |h, s|
|
425
|
+
h[s.name] = s
|
426
|
+
h
|
408
427
|
end
|
409
|
-
end
|
410
428
|
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
return Gem.dir unless loaded_from
|
416
|
-
File.dirname File.dirname loaded_from
|
417
|
-
end
|
418
|
-
end
|
429
|
+
Bundler.rubygems.default_stubs.each do |stub|
|
430
|
+
default_spec = stub.to_spec
|
431
|
+
default_spec_name = default_spec.name
|
432
|
+
next if specs_by_name.key?(default_spec_name)
|
419
433
|
|
420
|
-
|
421
|
-
|
422
|
-
@cache_dir ||= File.join base_dir, "cache"
|
434
|
+
specs << default_spec
|
435
|
+
specs_by_name[default_spec_name] = default_spec
|
423
436
|
end
|
424
437
|
|
425
|
-
|
426
|
-
@cache_file ||= File.join cache_dir, "#{full_name}.gem"
|
427
|
-
end
|
438
|
+
specs_by_name
|
428
439
|
end
|
429
440
|
|
430
|
-
def
|
431
|
-
|
432
|
-
|
433
|
-
end
|
434
|
-
|
435
|
-
redefine_method(Gem::Specification, :spec_file) do
|
436
|
-
@spec_file ||= File.join spec_dir, "#{full_name}.gemspec"
|
441
|
+
def undo_replacements
|
442
|
+
@replaced_methods.each do |(sym, klass), method|
|
443
|
+
redefine_method(klass, sym, method)
|
437
444
|
end
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
klass.send(:remove_method, method)
|
445
|
+
if Binding.public_method_defined?(:source_location)
|
446
|
+
post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
|
447
|
+
else
|
448
|
+
post_reset_hooks.reject! {|proc| proc.binding.eval("__FILE__") == __FILE__ }
|
443
449
|
end
|
444
|
-
|
450
|
+
@replaced_methods.clear
|
445
451
|
end
|
446
452
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
backport_spec_file
|
454
|
-
backport_yaml_initialize
|
455
|
-
end
|
456
|
-
|
457
|
-
def stub_rubygems(specs)
|
458
|
-
# Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
|
459
|
-
source_index_class = (class << Gem::SourceIndex; self; end)
|
460
|
-
source_index_class.send(:define_method, :from_gems_in) do |*args|
|
461
|
-
source_index = Gem::SourceIndex.new
|
462
|
-
source_index.spec_dirs = *args
|
463
|
-
source_index.add_specs(*specs)
|
464
|
-
source_index
|
453
|
+
def redefine_method(klass, method, unbound_method = nil, &block)
|
454
|
+
visibility = method_visibility(klass, method)
|
455
|
+
begin
|
456
|
+
if (instance_method = klass.instance_method(method)) && method != :initialize
|
457
|
+
# doing this to ensure we also get private methods
|
458
|
+
klass.send(:remove_method, method)
|
465
459
|
end
|
460
|
+
rescue NameError
|
461
|
+
# method isn't defined
|
462
|
+
nil
|
466
463
|
end
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
end
|
475
|
-
|
476
|
-
def validate(spec)
|
477
|
-
# These versions of RubyGems always validate in "packaging" mode,
|
478
|
-
# which is too strict for the kinds of checks we care about. As a
|
479
|
-
# result, validation is disabled on versions of RubyGems below 1.7.
|
464
|
+
@replaced_methods[[method, klass]] = instance_method
|
465
|
+
if unbound_method
|
466
|
+
klass.send(:define_method, method, unbound_method)
|
467
|
+
klass.send(visibility, method)
|
468
|
+
elsif block
|
469
|
+
klass.send(:define_method, method, &block)
|
470
|
+
klass.send(visibility, method)
|
480
471
|
end
|
481
472
|
end
|
482
473
|
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
474
|
+
def method_visibility(klass, method)
|
475
|
+
if klass.private_method_defined?(method)
|
476
|
+
:private
|
477
|
+
elsif klass.protected_method_defined?(method)
|
478
|
+
:protected
|
479
|
+
else
|
480
|
+
:public
|
488
481
|
end
|
489
482
|
end
|
490
483
|
|
491
|
-
|
492
|
-
|
493
|
-
def stub_rubygems(specs)
|
494
|
-
stub_source_index(specs)
|
495
|
-
end
|
496
|
-
|
497
|
-
def validate(spec)
|
498
|
-
# Missing summary is downgraded to a warning in later versions,
|
499
|
-
# so we set it to an empty string to prevent an exception here.
|
500
|
-
spec.summary ||= ""
|
501
|
-
Bundler.ui.silence { spec.validate(false) }
|
502
|
-
rescue Errno::ENOENT
|
503
|
-
nil
|
504
|
-
end
|
505
|
-
end
|
484
|
+
def stub_rubygems(specs)
|
485
|
+
Gem::Specification.all = specs
|
506
486
|
|
507
|
-
|
508
|
-
class Modern < RubygemsIntegration
|
509
|
-
def stub_rubygems(specs)
|
487
|
+
Gem.post_reset do
|
510
488
|
Gem::Specification.all = specs
|
511
|
-
|
512
|
-
Gem.post_reset do
|
513
|
-
Gem::Specification.all = specs
|
514
|
-
end
|
515
|
-
|
516
|
-
stub_source_index(specs)
|
517
489
|
end
|
518
490
|
|
519
|
-
|
520
|
-
|
491
|
+
redefine_method((class << Gem; self; end), :finish_resolve) do |*|
|
492
|
+
[]
|
521
493
|
end
|
494
|
+
end
|
522
495
|
|
523
|
-
|
524
|
-
|
525
|
-
end
|
496
|
+
def plain_specs
|
497
|
+
Gem::Specification._all
|
526
498
|
end
|
527
499
|
|
528
|
-
|
529
|
-
|
530
|
-
# Rubygems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever
|
531
|
-
# you call Gem::Installer#install with an :install_dir set. We have to
|
532
|
-
# change it back for our sudo mode to work.
|
533
|
-
def preserve_paths
|
534
|
-
old_dir = gem_dir
|
535
|
-
old_path = gem_path
|
536
|
-
yield
|
537
|
-
Gem.use_paths(old_dir, old_path)
|
538
|
-
end
|
500
|
+
def plain_specs=(specs)
|
501
|
+
Gem::Specification.all = specs
|
539
502
|
end
|
540
503
|
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
504
|
+
def fetch_specs(remote, name)
|
505
|
+
path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
|
506
|
+
fetcher = gem_remote_fetcher
|
507
|
+
fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
|
508
|
+
string = fetcher.fetch_path(path)
|
509
|
+
Bundler.load_marshal(string)
|
510
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
511
|
+
# it's okay for prerelease to fail
|
512
|
+
raise e unless name == "prerelease_specs"
|
549
513
|
end
|
550
514
|
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
Gem::Specification.all = specs
|
515
|
+
def fetch_all_remote_specs(remote)
|
516
|
+
specs = fetch_specs(remote, "specs")
|
517
|
+
pres = fetch_specs(remote, "prerelease_specs") || []
|
555
518
|
|
556
|
-
|
557
|
-
|
558
|
-
end
|
559
|
-
end
|
519
|
+
specs.concat(pres)
|
520
|
+
end
|
560
521
|
|
561
|
-
|
562
|
-
|
522
|
+
def download_gem(spec, uri, path)
|
523
|
+
uri = Bundler.settings.mirror_for(uri)
|
524
|
+
fetcher = gem_remote_fetcher
|
525
|
+
fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
|
526
|
+
Bundler::Retry.new("download gem from #{uri}").attempts do
|
527
|
+
fetcher.download(spec, uri, path)
|
563
528
|
end
|
529
|
+
end
|
564
530
|
|
565
|
-
|
566
|
-
|
567
|
-
|
531
|
+
def gem_remote_fetcher
|
532
|
+
require "resolv"
|
533
|
+
proxy = configuration[:http_proxy]
|
534
|
+
dns = Resolv::DNS.new
|
535
|
+
Gem::RemoteFetcher.new(proxy, dns)
|
536
|
+
end
|
568
537
|
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
rescue Gem::RemoteFetcher::FetchError => e
|
576
|
-
# it's okay for prerelease to fail
|
577
|
-
raise e unless name == "prerelease_specs"
|
578
|
-
end
|
538
|
+
def gem_from_path(path, policy = nil)
|
539
|
+
require "rubygems/package"
|
540
|
+
p = Gem::Package.new(path)
|
541
|
+
p.security_policy = policy if policy
|
542
|
+
p
|
543
|
+
end
|
579
544
|
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
545
|
+
def build(spec, skip_validation = false)
|
546
|
+
require "rubygems/package"
|
547
|
+
Gem::Package.build(spec, skip_validation)
|
548
|
+
end
|
584
549
|
|
585
|
-
|
586
|
-
|
587
|
-
|
550
|
+
def repository_subdirectories
|
551
|
+
Gem::REPOSITORY_SUBDIRECTORIES
|
552
|
+
end
|
588
553
|
|
589
|
-
|
590
|
-
|
554
|
+
def install_with_build_args(args)
|
555
|
+
yield
|
556
|
+
end
|
591
557
|
|
592
|
-
|
593
|
-
|
558
|
+
def path_separator
|
559
|
+
Gem.path_separator
|
560
|
+
end
|
594
561
|
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
|
599
|
-
fetcher.download(spec, uri, path)
|
562
|
+
def all_specs
|
563
|
+
Gem::Specification.stubs.map do |stub|
|
564
|
+
StubSpecification.from_stub(stub)
|
600
565
|
end
|
566
|
+
end
|
601
567
|
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
568
|
+
def backport_ext_builder_monitor
|
569
|
+
# So we can avoid requiring "rubygems/ext" in its entirety
|
570
|
+
Gem.module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
571
|
+
module Ext
|
572
|
+
end
|
573
|
+
RUBY
|
608
574
|
|
609
|
-
|
610
|
-
require "rubygems/package"
|
611
|
-
p = Gem::Package.new(path)
|
612
|
-
p.security_policy = policy if policy
|
613
|
-
p
|
614
|
-
end
|
575
|
+
require "rubygems/ext/builder"
|
615
576
|
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
577
|
+
Gem::Ext::Builder.class_eval do
|
578
|
+
unless const_defined?(:CHDIR_MONITOR)
|
579
|
+
const_set(:CHDIR_MONITOR, EXT_LOCK)
|
580
|
+
end
|
620
581
|
|
621
|
-
|
622
|
-
|
582
|
+
remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
|
583
|
+
const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
|
623
584
|
end
|
624
585
|
end
|
625
586
|
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
super
|
630
|
-
backport_ext_builder_monitor
|
631
|
-
end
|
632
|
-
|
633
|
-
def all_specs
|
634
|
-
require "bundler/remote_specification"
|
635
|
-
Gem::Specification.stubs.map do |stub|
|
636
|
-
StubSpecification.from_stub(stub)
|
637
|
-
end
|
638
|
-
end
|
639
|
-
|
640
|
-
def backport_ext_builder_monitor
|
641
|
-
require "rubygems/ext"
|
642
|
-
|
643
|
-
Gem::Ext::Builder.class_eval do
|
644
|
-
unless const_defined?(:CHDIR_MONITOR)
|
645
|
-
const_set(:CHDIR_MONITOR, EXT_LOCK)
|
646
|
-
end
|
587
|
+
def find_name(name)
|
588
|
+
Gem::Specification.stubs_for(name).map(&:to_spec)
|
589
|
+
end
|
647
590
|
|
648
|
-
|
649
|
-
|
650
|
-
|
591
|
+
if Gem::Specification.respond_to?(:default_stubs)
|
592
|
+
def default_stubs
|
593
|
+
Gem::Specification.default_stubs("*.gemspec")
|
651
594
|
end
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
Gem::Specification.stubs_for(name).map(&:to_spec)
|
656
|
-
end
|
657
|
-
else
|
658
|
-
def find_name(name)
|
659
|
-
Gem::Specification.stubs.find_all do |spec|
|
660
|
-
spec.name == name
|
661
|
-
end.map(&:to_spec)
|
662
|
-
end
|
595
|
+
else
|
596
|
+
def default_stubs
|
597
|
+
Gem::Specification.send(:default_stubs, "*.gemspec")
|
663
598
|
end
|
664
599
|
end
|
665
|
-
end
|
666
600
|
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
@rubygems = RubygemsIntegration::Modern.new
|
675
|
-
elsif RubygemsIntegration.provides?(">= 1.8.0")
|
676
|
-
@rubygems = RubygemsIntegration::AlmostModern.new
|
677
|
-
elsif RubygemsIntegration.provides?(">= 1.7.0")
|
678
|
-
@rubygems = RubygemsIntegration::Transitional.new
|
679
|
-
elsif RubygemsIntegration.provides?(">= 1.4.0")
|
680
|
-
@rubygems = RubygemsIntegration::Legacy.new
|
681
|
-
else # Rubygems 1.3.6 and 1.3.7
|
682
|
-
@rubygems = RubygemsIntegration::Ancient.new
|
601
|
+
def use_gemdeps(gemfile)
|
602
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
|
603
|
+
require_relative "gemdeps"
|
604
|
+
runtime = Bundler.setup
|
605
|
+
activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name)
|
606
|
+
[Gemdeps.new(runtime), activated_spec_names]
|
607
|
+
end
|
683
608
|
end
|
684
609
|
|
685
|
-
|
686
|
-
|
610
|
+
def self.rubygems
|
611
|
+
@rubygems ||= RubygemsIntegration.new
|
687
612
|
end
|
688
613
|
end
|