bundler 2.0.2
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 +7 -0
- data/CHANGELOG.md +3111 -0
- data/LICENSE.md +23 -0
- data/README.md +63 -0
- data/bundler.gemspec +65 -0
- data/exe/bundle +31 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +4 -0
- data/lib/bundler.rb +567 -0
- data/lib/bundler/build_metadata.rb +53 -0
- data/lib/bundler/capistrano.rb +22 -0
- data/lib/bundler/cli.rb +792 -0
- data/lib/bundler/cli/add.rb +35 -0
- data/lib/bundler/cli/binstubs.rb +49 -0
- data/lib/bundler/cli/cache.rb +36 -0
- data/lib/bundler/cli/check.rb +38 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +102 -0
- data/lib/bundler/cli/config.rb +119 -0
- data/lib/bundler/cli/console.rb +43 -0
- data/lib/bundler/cli/doctor.rb +140 -0
- data/lib/bundler/cli/exec.rb +105 -0
- data/lib/bundler/cli/gem.rb +252 -0
- data/lib/bundler/cli/info.rb +50 -0
- data/lib/bundler/cli/init.rb +47 -0
- data/lib/bundler/cli/inject.rb +60 -0
- data/lib/bundler/cli/install.rb +218 -0
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +58 -0
- data/lib/bundler/cli/lock.rb +63 -0
- data/lib/bundler/cli/open.rb +26 -0
- data/lib/bundler/cli/outdated.rb +266 -0
- data/lib/bundler/cli/package.rb +49 -0
- data/lib/bundler/cli/platform.rb +46 -0
- data/lib/bundler/cli/plugin.rb +24 -0
- data/lib/bundler/cli/pristine.rb +47 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +75 -0
- data/lib/bundler/cli/update.rb +91 -0
- data/lib/bundler/cli/viz.rb +31 -0
- 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 +13 -0
- data/lib/bundler/constants.rb +7 -0
- data/lib/bundler/current_ruby.rb +94 -0
- data/lib/bundler/definition.rb +995 -0
- data/lib/bundler/dep_proxy.rb +48 -0
- data/lib/bundler/dependency.rb +139 -0
- data/lib/bundler/deployment.rb +69 -0
- data/lib/bundler/deprecate.rb +44 -0
- data/lib/bundler/dsl.rb +615 -0
- data/lib/bundler/endpoint_specification.rb +141 -0
- data/lib/bundler/env.rb +149 -0
- data/lib/bundler/environment_preserver.rb +59 -0
- data/lib/bundler/errors.rb +158 -0
- data/lib/bundler/feature_flag.rb +75 -0
- data/lib/bundler/fetcher.rb +312 -0
- data/lib/bundler/fetcher/base.rb +52 -0
- data/lib/bundler/fetcher/compact_index.rb +126 -0
- data/lib/bundler/fetcher/dependency.rb +82 -0
- data/lib/bundler/fetcher/downloader.rb +84 -0
- data/lib/bundler/fetcher/index.rb +52 -0
- data/lib/bundler/friendly_errors.rb +131 -0
- data/lib/bundler/gem_helper.rb +217 -0
- data/lib/bundler/gem_helpers.rb +101 -0
- data/lib/bundler/gem_remote_fetcher.rb +43 -0
- data/lib/bundler/gem_tasks.rb +7 -0
- data/lib/bundler/gem_version_promoter.rb +190 -0
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +152 -0
- data/lib/bundler/index.rb +213 -0
- data/lib/bundler/injector.rb +253 -0
- data/lib/bundler/inline.rb +74 -0
- data/lib/bundler/installer.rb +318 -0
- data/lib/bundler/installer/gem_installer.rb +85 -0
- data/lib/bundler/installer/parallel_installer.rb +229 -0
- data/lib/bundler/installer/standalone.rb +53 -0
- data/lib/bundler/lazy_specification.rb +123 -0
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +256 -0
- data/lib/bundler/match_platform.rb +24 -0
- data/lib/bundler/mirror.rb +223 -0
- data/lib/bundler/plugin.rb +294 -0
- data/lib/bundler/plugin/api.rb +81 -0
- data/lib/bundler/plugin/api/source.rb +306 -0
- data/lib/bundler/plugin/dsl.rb +53 -0
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +165 -0
- data/lib/bundler/plugin/installer.rb +96 -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 +37 -0
- data/lib/bundler/remote_specification.rb +114 -0
- data/lib/bundler/resolver.rb +373 -0
- data/lib/bundler/resolver/spec_group.rb +106 -0
- data/lib/bundler/retry.rb +66 -0
- data/lib/bundler/ruby_dsl.rb +18 -0
- data/lib/bundler/ruby_version.rb +152 -0
- data/lib/bundler/rubygems_ext.rb +209 -0
- data/lib/bundler/rubygems_gem_installer.rb +99 -0
- data/lib/bundler/rubygems_integration.rb +915 -0
- data/lib/bundler/runtime.rb +322 -0
- data/lib/bundler/settings.rb +464 -0
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +28 -0
- data/lib/bundler/shared_helpers.rb +386 -0
- data/lib/bundler/similarity_detector.rb +63 -0
- data/lib/bundler/source.rb +94 -0
- data/lib/bundler/source/gemspec.rb +18 -0
- data/lib/bundler/source/git.rb +329 -0
- data/lib/bundler/source/git/git_proxy.rb +262 -0
- data/lib/bundler/source/metadata.rb +62 -0
- data/lib/bundler/source/path.rb +249 -0
- data/lib/bundler/source/path/installer.rb +74 -0
- data/lib/bundler/source/rubygems.rb +539 -0
- data/lib/bundler/source/rubygems/remote.rb +69 -0
- data/lib/bundler/source_list.rb +186 -0
- data/lib/bundler/spec_set.rb +208 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +66 -0
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
- data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
- data/lib/bundler/stub_specification.rb +108 -0
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +29 -0
- data/lib/bundler/templates/Executable.bundler +105 -0
- data/lib/bundler/templates/Executable.standalone +14 -0
- data/lib/bundler/templates/Gemfile +7 -0
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
- data/lib/bundler/templates/newgem/README.md.tt +47 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +29 -0
- data/lib/bundler/templates/newgem/bin/console.tt +14 -0
- data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
- data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
- data/lib/bundler/templates/newgem/gitignore.tt +20 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +13 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +50 -0
- data/lib/bundler/templates/newgem/rspec.tt +3 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +9 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +14 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +8 -0
- data/lib/bundler/templates/newgem/travis.yml.tt +7 -0
- data/lib/bundler/ui.rb +9 -0
- data/lib/bundler/ui/rg_proxy.rb +19 -0
- data/lib/bundler/ui/shell.rb +146 -0
- data/lib/bundler/ui/silent.rb +69 -0
- data/lib/bundler/uri_credentials_filter.rb +37 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1741 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +12 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
- 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 +223 -0
- 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 +136 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +143 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +101 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +67 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +837 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +58 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1233 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +509 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +331 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +104 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +60 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +373 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +678 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +97 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +114 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +177 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +70 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +146 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +226 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +324 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +482 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/lib/bundler/vendor/thor/lib/thor/util.rb +268 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_fileutils.rb +9 -0
- data/lib/bundler/vendored_molinillo.rb +4 -0
- data/lib/bundler/vendored_persistent.rb +52 -0
- data/lib/bundler/vendored_thor.rb +8 -0
- data/lib/bundler/version.rb +28 -0
- data/lib/bundler/version_ranges.rb +76 -0
- data/lib/bundler/vlad.rb +17 -0
- data/lib/bundler/worker.rb +106 -0
- data/lib/bundler/yaml_serializer.rb +90 -0
- data/man/bundle-add.1 +58 -0
- data/man/bundle-add.1.txt +52 -0
- data/man/bundle-add.ronn +40 -0
- data/man/bundle-binstubs.1 +40 -0
- data/man/bundle-binstubs.1.txt +48 -0
- data/man/bundle-binstubs.ronn +43 -0
- 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 +397 -0
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/man/bundle-exec.1 +165 -0
- data/man/bundle-exec.1.txt +178 -0
- data/man/bundle-exec.ronn +152 -0
- data/man/bundle-gem.1 +80 -0
- data/man/bundle-gem.1.txt +91 -0
- data/man/bundle-gem.ronn +78 -0
- 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/man/bundle-install.1 +308 -0
- data/man/bundle-install.1.txt +396 -0
- data/man/bundle-install.ronn +378 -0
- data/man/bundle-list.1 +50 -0
- data/man/bundle-list.1.txt +43 -0
- data/man/bundle-list.ronn +33 -0
- data/man/bundle-lock.1 +84 -0
- data/man/bundle-lock.1.txt +93 -0
- data/man/bundle-lock.ronn +94 -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/man/bundle-package.1 +55 -0
- data/man/bundle-package.1.txt +79 -0
- data/man/bundle-package.ronn +72 -0
- data/man/bundle-platform.1 +61 -0
- data/man/bundle-platform.1.txt +57 -0
- data/man/bundle-platform.ronn +42 -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 +350 -0
- data/man/bundle-viz.1 +39 -0
- data/man/bundle-viz.1.txt +39 -0
- data/man/bundle-viz.ronn +30 -0
- data/man/bundle.1 +136 -0
- data/man/bundle.1.txt +116 -0
- data/man/bundle.ronn +111 -0
- data/man/gemfile.5 +689 -0
- data/man/gemfile.5.ronn +521 -0
- data/man/gemfile.5.txt +653 -0
- data/man/index.txt +25 -0
- metadata +463 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Settings
|
5
|
+
class Validator
|
6
|
+
class Rule
|
7
|
+
attr_reader :description
|
8
|
+
|
9
|
+
def initialize(keys, description, &validate)
|
10
|
+
@keys = keys
|
11
|
+
@description = description
|
12
|
+
@validate = validate
|
13
|
+
end
|
14
|
+
|
15
|
+
def validate!(key, value, settings)
|
16
|
+
instance_exec(key, value, settings, &@validate)
|
17
|
+
end
|
18
|
+
|
19
|
+
def fail!(key, value, *reasons)
|
20
|
+
reasons.unshift @description
|
21
|
+
raise InvalidOption, "Setting `#{key}` to #{value.inspect} failed:\n#{reasons.map {|r| " - #{r}" }.join("\n")}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def set(settings, key, value, *reasons)
|
25
|
+
hash_key = k(key)
|
26
|
+
return if settings[hash_key] == value
|
27
|
+
reasons.unshift @description
|
28
|
+
Bundler.ui.info "Setting `#{key}` to #{value.inspect}, since #{reasons.join(", ")}"
|
29
|
+
if value.nil?
|
30
|
+
settings.delete(hash_key)
|
31
|
+
else
|
32
|
+
settings[hash_key] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def k(key)
|
37
|
+
Bundler.settings.key_for(key)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.rules
|
42
|
+
@rules ||= Hash.new {|h, k| h[k] = [] }
|
43
|
+
end
|
44
|
+
private_class_method :rules
|
45
|
+
|
46
|
+
def self.rule(keys, description, &blk)
|
47
|
+
rule = Rule.new(keys, description, &blk)
|
48
|
+
keys.each {|k| rules[k] << rule }
|
49
|
+
end
|
50
|
+
private_class_method :rule
|
51
|
+
|
52
|
+
def self.validate!(key, value, settings)
|
53
|
+
rules_to_validate = rules[key]
|
54
|
+
rules_to_validate.each {|rule| rule.validate!(key, value, settings) }
|
55
|
+
end
|
56
|
+
|
57
|
+
rule %w[path path.system], "path and path.system are mutually exclusive" do |key, value, settings|
|
58
|
+
if key == "path" && value
|
59
|
+
set(settings, "path.system", nil)
|
60
|
+
elsif key == "path.system" && value
|
61
|
+
set(settings, :path, nil)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
rule %w[with without], "a group cannot be in both `with` & `without` simultaneously" do |key, value, settings|
|
66
|
+
with = settings.fetch(k(:with), "").split(":").map(&:to_sym)
|
67
|
+
without = settings.fetch(k(:without), "").split(":").map(&:to_sym)
|
68
|
+
|
69
|
+
other_key = key == "with" ? :without : :with
|
70
|
+
other_setting = key == "with" ? without : with
|
71
|
+
|
72
|
+
conflicting = with & without
|
73
|
+
if conflicting.any?
|
74
|
+
fail!(key, value, "`#{other_key}` is current set to #{other_setting.inspect}", "the `#{conflicting.join("`, `")}` groups conflict")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
rule %w[path], "relative paths are expanded relative to the current working directory" do |key, value, settings|
|
79
|
+
next if value.nil?
|
80
|
+
|
81
|
+
path = Pathname.new(value)
|
82
|
+
next if !path.relative? || !Bundler.feature_flag.path_relative_to_cwd?
|
83
|
+
|
84
|
+
path = path.expand_path
|
85
|
+
|
86
|
+
root = begin
|
87
|
+
Bundler.root
|
88
|
+
rescue GemfileNotFound
|
89
|
+
Pathname.pwd.expand_path
|
90
|
+
end
|
91
|
+
|
92
|
+
path = begin
|
93
|
+
path.relative_path_from(root)
|
94
|
+
rescue ArgumentError
|
95
|
+
path
|
96
|
+
end
|
97
|
+
|
98
|
+
set(settings, key, path.to_s)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/shared_helpers"
|
4
|
+
|
5
|
+
if Bundler::SharedHelpers.in_bundle?
|
6
|
+
require "bundler"
|
7
|
+
|
8
|
+
if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"]
|
9
|
+
begin
|
10
|
+
Bundler.setup
|
11
|
+
rescue Bundler::BundlerError => e
|
12
|
+
puts "\e[31m#{e.message}\e[0m"
|
13
|
+
puts e.backtrace.join("\n") if ENV["DEBUG"]
|
14
|
+
if e.is_a?(Bundler::GemNotFound)
|
15
|
+
puts "\e[33mRun `bundle install` to install missing gems.\e[0m"
|
16
|
+
end
|
17
|
+
exit e.status_code
|
18
|
+
end
|
19
|
+
else
|
20
|
+
Bundler.setup
|
21
|
+
end
|
22
|
+
|
23
|
+
# Add bundler to the load path after disabling system gems
|
24
|
+
bundler_lib = File.expand_path("../..", __FILE__)
|
25
|
+
$LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib)
|
26
|
+
|
27
|
+
Bundler.ui = nil
|
28
|
+
end
|
@@ -0,0 +1,386 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/compatibility_guard"
|
4
|
+
|
5
|
+
require "pathname"
|
6
|
+
require "rbconfig"
|
7
|
+
require "rubygems"
|
8
|
+
|
9
|
+
require "bundler/version"
|
10
|
+
require "bundler/constants"
|
11
|
+
require "bundler/rubygems_integration"
|
12
|
+
require "bundler/current_ruby"
|
13
|
+
|
14
|
+
module Gem
|
15
|
+
class Dependency
|
16
|
+
# This is only needed for RubyGems < 1.4
|
17
|
+
unless method_defined? :requirement
|
18
|
+
def requirement
|
19
|
+
version_requirements
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Bundler
|
26
|
+
module SharedHelpers
|
27
|
+
def root
|
28
|
+
gemfile = find_gemfile
|
29
|
+
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
|
30
|
+
Pathname.new(gemfile).untaint.expand_path.parent
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_gemfile
|
34
|
+
gemfile = find_gemfile(:order_matters)
|
35
|
+
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
|
36
|
+
Pathname.new(gemfile).untaint.expand_path
|
37
|
+
end
|
38
|
+
|
39
|
+
def default_lockfile
|
40
|
+
gemfile = default_gemfile
|
41
|
+
|
42
|
+
case gemfile.basename.to_s
|
43
|
+
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
|
44
|
+
else Pathname.new("#{gemfile}.lock")
|
45
|
+
end.untaint
|
46
|
+
end
|
47
|
+
|
48
|
+
def default_bundle_dir
|
49
|
+
bundle_dir = find_directory(".bundle")
|
50
|
+
return nil unless bundle_dir
|
51
|
+
|
52
|
+
bundle_dir = Pathname.new(bundle_dir)
|
53
|
+
|
54
|
+
global_bundle_dir = Bundler.user_home.join(".bundle")
|
55
|
+
return nil if bundle_dir == global_bundle_dir
|
56
|
+
|
57
|
+
bundle_dir
|
58
|
+
end
|
59
|
+
|
60
|
+
def in_bundle?
|
61
|
+
find_gemfile
|
62
|
+
end
|
63
|
+
|
64
|
+
def chdir(dir, &blk)
|
65
|
+
Bundler.rubygems.ext_lock.synchronize do
|
66
|
+
Dir.chdir dir, &blk
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def pwd
|
71
|
+
Bundler.rubygems.ext_lock.synchronize do
|
72
|
+
Pathname.pwd
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def with_clean_git_env(&block)
|
77
|
+
keys = %w[GIT_DIR GIT_WORK_TREE]
|
78
|
+
old_env = keys.inject({}) do |h, k|
|
79
|
+
h.update(k => ENV[k])
|
80
|
+
end
|
81
|
+
|
82
|
+
keys.each {|key| ENV.delete(key) }
|
83
|
+
|
84
|
+
block.call
|
85
|
+
ensure
|
86
|
+
keys.each {|key| ENV[key] = old_env[key] }
|
87
|
+
end
|
88
|
+
|
89
|
+
def set_bundle_environment
|
90
|
+
set_bundle_variables
|
91
|
+
set_path
|
92
|
+
set_rubyopt
|
93
|
+
set_rubylib
|
94
|
+
end
|
95
|
+
|
96
|
+
# Rescues permissions errors raised by file system operations
|
97
|
+
# (ie. Errno:EACCESS, Errno::EAGAIN) and raises more friendly errors instead.
|
98
|
+
#
|
99
|
+
# @param path [String] the path that the action will be attempted to
|
100
|
+
# @param action [Symbol, #to_s] the type of operation that will be
|
101
|
+
# performed. For example: :write, :read, :exec
|
102
|
+
#
|
103
|
+
# @yield path
|
104
|
+
#
|
105
|
+
# @raise [Bundler::PermissionError] if Errno:EACCES is raised in the
|
106
|
+
# given block
|
107
|
+
# @raise [Bundler::TemporaryResourceError] if Errno:EAGAIN is raised in the
|
108
|
+
# given block
|
109
|
+
#
|
110
|
+
# @example
|
111
|
+
# filesystem_access("vendor/cache", :write) do
|
112
|
+
# FileUtils.mkdir_p("vendor/cache")
|
113
|
+
# end
|
114
|
+
#
|
115
|
+
# @see {Bundler::PermissionError}
|
116
|
+
def filesystem_access(path, action = :write, &block)
|
117
|
+
# Use block.call instead of yield because of a bug in Ruby 2.2.2
|
118
|
+
# See https://github.com/bundler/bundler/issues/5341 for details
|
119
|
+
block.call(path.dup.untaint)
|
120
|
+
rescue Errno::EACCES
|
121
|
+
raise PermissionError.new(path, action)
|
122
|
+
rescue Errno::EAGAIN
|
123
|
+
raise TemporaryResourceError.new(path, action)
|
124
|
+
rescue Errno::EPROTO
|
125
|
+
raise VirtualProtocolError.new
|
126
|
+
rescue Errno::ENOSPC
|
127
|
+
raise NoSpaceOnDeviceError.new(path, action)
|
128
|
+
rescue *[const_get_safely(:ENOTSUP, Errno)].compact
|
129
|
+
raise OperationNotSupportedError.new(path, action)
|
130
|
+
rescue Errno::EEXIST, Errno::ENOENT
|
131
|
+
raise
|
132
|
+
rescue SystemCallError => e
|
133
|
+
raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
|
134
|
+
end
|
135
|
+
|
136
|
+
def const_get_safely(constant_name, namespace)
|
137
|
+
const_in_namespace = namespace.constants.include?(constant_name.to_s) ||
|
138
|
+
namespace.constants.include?(constant_name.to_sym)
|
139
|
+
return nil unless const_in_namespace
|
140
|
+
namespace.const_get(constant_name)
|
141
|
+
end
|
142
|
+
|
143
|
+
def major_deprecation(major_version, message)
|
144
|
+
bundler_major_version = Bundler.bundler_major_version
|
145
|
+
if bundler_major_version > major_version
|
146
|
+
require "bundler/errors"
|
147
|
+
raise DeprecatedError, "[REMOVED FROM #{major_version.succ}.0] #{message}"
|
148
|
+
end
|
149
|
+
|
150
|
+
return unless bundler_major_version >= major_version || prints_major_deprecations?
|
151
|
+
@major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
|
152
|
+
ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui
|
153
|
+
ui.warn("[DEPRECATED FOR #{major_version}.0] #{message}")
|
154
|
+
end
|
155
|
+
|
156
|
+
def print_major_deprecations!
|
157
|
+
multiple_gemfiles = search_up(".") do |dir|
|
158
|
+
gemfiles = gemfile_names.select {|gf| File.file? File.expand_path(gf, dir) }
|
159
|
+
next if gemfiles.empty?
|
160
|
+
break false if gemfiles.size == 1
|
161
|
+
end
|
162
|
+
if multiple_gemfiles && Bundler.bundler_major_version == 2
|
163
|
+
Bundler::SharedHelpers.major_deprecation 3, \
|
164
|
+
"gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock."
|
165
|
+
end
|
166
|
+
|
167
|
+
if RUBY_VERSION < "2"
|
168
|
+
major_deprecation(2, "Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}")
|
169
|
+
end
|
170
|
+
return if Bundler.rubygems.provides?(">= 2")
|
171
|
+
major_deprecation(2, "Bundler will only support rubygems >= 2.0, you are running #{Bundler.rubygems.version}")
|
172
|
+
end
|
173
|
+
|
174
|
+
def trap(signal, override = false, &block)
|
175
|
+
prior = Signal.trap(signal) do
|
176
|
+
block.call
|
177
|
+
prior.call unless override
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def ensure_same_dependencies(spec, old_deps, new_deps)
|
182
|
+
new_deps = new_deps.reject {|d| d.type == :development }
|
183
|
+
old_deps = old_deps.reject {|d| d.type == :development }
|
184
|
+
|
185
|
+
without_type = proc {|d| Gem::Dependency.new(d.name, d.requirements_list.sort) }
|
186
|
+
new_deps.map!(&without_type)
|
187
|
+
old_deps.map!(&without_type)
|
188
|
+
|
189
|
+
extra_deps = new_deps - old_deps
|
190
|
+
return if extra_deps.empty?
|
191
|
+
|
192
|
+
Bundler.ui.debug "#{spec.full_name} from #{spec.remote} has either corrupted API or lockfile dependencies" \
|
193
|
+
" (was expecting #{old_deps.map(&:to_s)}, but the real spec has #{new_deps.map(&:to_s)})"
|
194
|
+
raise APIResponseMismatchError,
|
195
|
+
"Downloading #{spec.full_name} revealed dependencies not in the API or the lockfile (#{extra_deps.join(", ")})." \
|
196
|
+
"\nEither installing with `--full-index` or running `bundle update #{spec.name}` should fix the problem."
|
197
|
+
end
|
198
|
+
|
199
|
+
def pretty_dependency(dep, print_source = false)
|
200
|
+
msg = String.new(dep.name)
|
201
|
+
msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
|
202
|
+
|
203
|
+
if dep.is_a?(Bundler::Dependency)
|
204
|
+
platform_string = dep.platforms.join(", ")
|
205
|
+
msg << " " << platform_string if !platform_string.empty? && platform_string != Gem::Platform::RUBY
|
206
|
+
end
|
207
|
+
|
208
|
+
msg << " from the `#{dep.source}` source" if print_source && dep.source
|
209
|
+
msg
|
210
|
+
end
|
211
|
+
|
212
|
+
def md5_available?
|
213
|
+
return @md5_available if defined?(@md5_available)
|
214
|
+
@md5_available = begin
|
215
|
+
require "openssl"
|
216
|
+
OpenSSL::Digest::MD5.digest("")
|
217
|
+
true
|
218
|
+
rescue LoadError
|
219
|
+
true
|
220
|
+
rescue OpenSSL::Digest::DigestError
|
221
|
+
false
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def digest(name)
|
226
|
+
require "digest"
|
227
|
+
Digest(name)
|
228
|
+
end
|
229
|
+
|
230
|
+
def write_to_gemfile(gemfile_path, contents)
|
231
|
+
filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
|
232
|
+
end
|
233
|
+
|
234
|
+
private
|
235
|
+
|
236
|
+
def validate_bundle_path
|
237
|
+
path_separator = Bundler.rubygems.path_separator
|
238
|
+
return unless Bundler.bundle_path.to_s.split(path_separator).size > 1
|
239
|
+
message = "Your bundle path contains text matching #{path_separator.inspect}, " \
|
240
|
+
"which is the path separator for your system. Bundler cannot " \
|
241
|
+
"function correctly when the Bundle path contains the " \
|
242
|
+
"system's PATH separator. Please change your " \
|
243
|
+
"bundle path to not match #{path_separator.inspect}." \
|
244
|
+
"\nYour current bundle path is '#{Bundler.bundle_path}'."
|
245
|
+
raise Bundler::PathError, message
|
246
|
+
end
|
247
|
+
|
248
|
+
def find_gemfile(order_matters = false)
|
249
|
+
given = ENV["BUNDLE_GEMFILE"]
|
250
|
+
return given if given && !given.empty?
|
251
|
+
names = gemfile_names
|
252
|
+
names.reverse! if order_matters && Bundler.feature_flag.prefer_gems_rb?
|
253
|
+
find_file(*names)
|
254
|
+
end
|
255
|
+
|
256
|
+
def gemfile_names
|
257
|
+
["Gemfile", "gems.rb"]
|
258
|
+
end
|
259
|
+
|
260
|
+
def find_file(*names)
|
261
|
+
search_up(*names) do |filename|
|
262
|
+
return filename if File.file?(filename)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def find_directory(*names)
|
267
|
+
search_up(*names) do |dirname|
|
268
|
+
return dirname if File.directory?(dirname)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def search_up(*names)
|
273
|
+
previous = nil
|
274
|
+
current = File.expand_path(SharedHelpers.pwd).untaint
|
275
|
+
|
276
|
+
until !File.directory?(current) || current == previous
|
277
|
+
if ENV["BUNDLE_SPEC_RUN"]
|
278
|
+
# avoid stepping above the tmp directory when testing
|
279
|
+
gemspec = if ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]
|
280
|
+
# for Ruby Core
|
281
|
+
"lib/bundler/bundler.gemspec"
|
282
|
+
else
|
283
|
+
"bundler.gemspec"
|
284
|
+
end
|
285
|
+
|
286
|
+
# avoid stepping above the tmp directory when testing
|
287
|
+
return nil if File.file?(File.join(current, gemspec))
|
288
|
+
end
|
289
|
+
|
290
|
+
names.each do |name|
|
291
|
+
filename = File.join(current, name)
|
292
|
+
yield filename
|
293
|
+
end
|
294
|
+
previous = current
|
295
|
+
current = File.expand_path("..", current)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
def set_env(key, value)
|
300
|
+
raise ArgumentError, "new key #{key}" unless EnvironmentPreserver::BUNDLER_KEYS.include?(key)
|
301
|
+
orig_key = "#{EnvironmentPreserver::BUNDLER_PREFIX}#{key}"
|
302
|
+
orig = ENV[key]
|
303
|
+
orig ||= EnvironmentPreserver::INTENTIONALLY_NIL
|
304
|
+
ENV[orig_key] ||= orig
|
305
|
+
|
306
|
+
ENV[key] = value
|
307
|
+
end
|
308
|
+
public :set_env
|
309
|
+
|
310
|
+
def set_bundle_variables
|
311
|
+
begin
|
312
|
+
exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
|
313
|
+
unless File.exist?(exe_file)
|
314
|
+
exe_file = File.expand_path("../../../exe/bundle", __FILE__)
|
315
|
+
end
|
316
|
+
Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
|
317
|
+
rescue Gem::GemNotFoundException
|
318
|
+
exe_file = File.expand_path("../../../exe/bundle", __FILE__)
|
319
|
+
# for Ruby core repository
|
320
|
+
exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file)
|
321
|
+
Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
|
322
|
+
end
|
323
|
+
|
324
|
+
# Set BUNDLE_GEMFILE
|
325
|
+
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s
|
326
|
+
Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
|
327
|
+
end
|
328
|
+
|
329
|
+
def set_path
|
330
|
+
validate_bundle_path
|
331
|
+
paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
|
332
|
+
paths.unshift "#{Bundler.bundle_path}/bin"
|
333
|
+
Bundler::SharedHelpers.set_env "PATH", paths.uniq.join(File::PATH_SEPARATOR)
|
334
|
+
end
|
335
|
+
|
336
|
+
def set_rubyopt
|
337
|
+
rubyopt = [ENV["RUBYOPT"]].compact
|
338
|
+
return if !rubyopt.empty? && rubyopt.first =~ %r{-rbundler/setup}
|
339
|
+
rubyopt.unshift %(-rbundler/setup)
|
340
|
+
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
|
341
|
+
end
|
342
|
+
|
343
|
+
def set_rubylib
|
344
|
+
rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
|
345
|
+
rubylib.unshift bundler_ruby_lib unless RbConfig::CONFIG["rubylibdir"] == bundler_ruby_lib
|
346
|
+
Bundler::SharedHelpers.set_env "RUBYLIB", rubylib.uniq.join(File::PATH_SEPARATOR)
|
347
|
+
end
|
348
|
+
|
349
|
+
def bundler_ruby_lib
|
350
|
+
resolve_path File.expand_path("../..", __FILE__)
|
351
|
+
end
|
352
|
+
|
353
|
+
def clean_load_path
|
354
|
+
# handle 1.9 where system gems are always on the load path
|
355
|
+
return unless defined?(::Gem)
|
356
|
+
|
357
|
+
bundler_lib = bundler_ruby_lib
|
358
|
+
|
359
|
+
loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
|
360
|
+
|
361
|
+
$LOAD_PATH.reject! do |p|
|
362
|
+
next if resolve_path(p).start_with?(bundler_lib)
|
363
|
+
loaded_gem_paths.delete(p)
|
364
|
+
end
|
365
|
+
$LOAD_PATH.uniq!
|
366
|
+
end
|
367
|
+
|
368
|
+
def resolve_path(path)
|
369
|
+
expanded = File.expand_path(path)
|
370
|
+
return expanded unless File.respond_to?(:realpath) && File.exist?(expanded)
|
371
|
+
|
372
|
+
File.realpath(expanded)
|
373
|
+
end
|
374
|
+
|
375
|
+
def prints_major_deprecations?
|
376
|
+
require "bundler"
|
377
|
+
deprecation_release = Bundler::VERSION.split(".").drop(1).include?("99")
|
378
|
+
return false if !deprecation_release && !Bundler.settings[:major_deprecations]
|
379
|
+
require "bundler/deprecate"
|
380
|
+
return false if Bundler::Deprecate.skip
|
381
|
+
true
|
382
|
+
end
|
383
|
+
|
384
|
+
extend self
|
385
|
+
end
|
386
|
+
end
|