bundler 2.2.11 → 2.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +721 -5
  3. data/README.md +1 -1
  4. data/bundler.gemspec +8 -11
  5. data/exe/bundle +7 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/cli/cache.rb +1 -1
  10. data/lib/bundler/cli/check.rb +4 -2
  11. data/lib/bundler/cli/common.rb +17 -3
  12. data/lib/bundler/cli/config.rb +10 -1
  13. data/lib/bundler/cli/doctor.rb +24 -5
  14. data/lib/bundler/cli/exec.rb +1 -6
  15. data/lib/bundler/cli/gem.rb +130 -26
  16. data/lib/bundler/cli/info.rb +27 -6
  17. data/lib/bundler/cli/init.rb +5 -1
  18. data/lib/bundler/cli/install.rb +23 -54
  19. data/lib/bundler/cli/issue.rb +4 -3
  20. data/lib/bundler/cli/list.rb +7 -1
  21. data/lib/bundler/cli/lock.rb +5 -1
  22. data/lib/bundler/cli/open.rb +1 -2
  23. data/lib/bundler/cli/outdated.rb +22 -14
  24. data/lib/bundler/cli/platform.rb +2 -2
  25. data/lib/bundler/cli/remove.rb +1 -2
  26. data/lib/bundler/cli/show.rb +1 -1
  27. data/lib/bundler/cli/update.rb +17 -8
  28. data/lib/bundler/cli.rb +51 -63
  29. data/lib/bundler/compact_index_client/cache.rb +0 -9
  30. data/lib/bundler/compact_index_client/updater.rb +26 -14
  31. data/lib/bundler/compact_index_client.rb +2 -8
  32. data/lib/bundler/current_ruby.rb +17 -6
  33. data/lib/bundler/definition.rb +260 -362
  34. data/lib/bundler/dependency.rb +23 -71
  35. data/lib/bundler/digest.rb +71 -0
  36. data/lib/bundler/dsl.rb +72 -76
  37. data/lib/bundler/endpoint_specification.rb +19 -13
  38. data/lib/bundler/env.rb +1 -1
  39. data/lib/bundler/environment_preserver.rb +4 -1
  40. data/lib/bundler/errors.rb +29 -3
  41. data/lib/bundler/feature_flag.rb +0 -5
  42. data/lib/bundler/fetcher/base.rb +6 -8
  43. data/lib/bundler/fetcher/compact_index.rb +10 -15
  44. data/lib/bundler/fetcher/downloader.rb +9 -6
  45. data/lib/bundler/fetcher/index.rb +0 -27
  46. data/lib/bundler/fetcher.rb +22 -23
  47. data/lib/bundler/friendly_errors.rb +26 -36
  48. data/lib/bundler/gem_helper.rb +21 -16
  49. data/lib/bundler/gem_helpers.rb +9 -2
  50. data/lib/bundler/gem_version_promoter.rb +14 -25
  51. data/lib/bundler/index.rb +11 -46
  52. data/lib/bundler/injector.rb +18 -4
  53. data/lib/bundler/inline.rb +4 -13
  54. data/lib/bundler/installer/gem_installer.rb +16 -21
  55. data/lib/bundler/installer/parallel_installer.rb +36 -15
  56. data/lib/bundler/installer/standalone.rb +42 -10
  57. data/lib/bundler/installer.rb +25 -41
  58. data/lib/bundler/lazy_specification.rb +52 -30
  59. data/lib/bundler/lockfile_generator.rb +2 -2
  60. data/lib/bundler/lockfile_parser.rb +18 -43
  61. data/lib/bundler/man/bundle-add.1 +21 -5
  62. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  63. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  64. data/lib/bundler/man/bundle-cache.1 +7 -1
  65. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  66. data/lib/bundler/man/bundle-check.1 +1 -1
  67. data/lib/bundler/man/bundle-clean.1 +2 -2
  68. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  69. data/lib/bundler/man/bundle-config.1 +49 -22
  70. data/lib/bundler/man/bundle-config.1.ronn +49 -30
  71. data/lib/bundler/man/bundle-console.1 +53 -0
  72. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  73. data/lib/bundler/man/bundle-doctor.1 +1 -1
  74. data/lib/bundler/man/bundle-exec.1 +2 -2
  75. data/lib/bundler/man/bundle-exec.1.ronn +1 -1
  76. data/lib/bundler/man/bundle-gem.1 +14 -1
  77. data/lib/bundler/man/bundle-gem.1.ronn +16 -0
  78. data/lib/bundler/man/bundle-help.1 +13 -0
  79. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  80. data/lib/bundler/man/bundle-info.1 +1 -1
  81. data/lib/bundler/man/bundle-init.1 +1 -1
  82. data/lib/bundler/man/bundle-inject.1 +5 -2
  83. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  84. data/lib/bundler/man/bundle-install.1 +6 -2
  85. data/lib/bundler/man/bundle-install.1.ronn +8 -2
  86. data/lib/bundler/man/bundle-list.1 +1 -1
  87. data/lib/bundler/man/bundle-lock.1 +1 -1
  88. data/lib/bundler/man/bundle-open.1 +1 -1
  89. data/lib/bundler/man/bundle-outdated.1 +3 -10
  90. data/lib/bundler/man/bundle-outdated.1.ronn +1 -10
  91. data/lib/bundler/man/bundle-platform.1 +16 -6
  92. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  93. data/lib/bundler/man/bundle-plugin.1 +81 -0
  94. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  95. data/lib/bundler/man/bundle-pristine.1 +1 -1
  96. data/lib/bundler/man/bundle-remove.1 +1 -1
  97. data/lib/bundler/man/bundle-show.1 +1 -1
  98. data/lib/bundler/man/bundle-update.1 +5 -5
  99. data/lib/bundler/man/bundle-update.1.ronn +5 -4
  100. data/lib/bundler/man/bundle-version.1 +35 -0
  101. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  102. data/lib/bundler/man/bundle-viz.1 +4 -1
  103. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  104. data/lib/bundler/man/bundle.1 +15 -10
  105. data/lib/bundler/man/bundle.1.ronn +12 -7
  106. data/lib/bundler/man/gemfile.5 +117 -80
  107. data/lib/bundler/man/gemfile.5.ronn +105 -84
  108. data/lib/bundler/man/index.txt +4 -0
  109. data/lib/bundler/match_metadata.rb +13 -0
  110. data/lib/bundler/match_platform.rb +0 -1
  111. data/lib/bundler/match_remote_metadata.rb +29 -0
  112. data/lib/bundler/plugin/api/source.rb +24 -8
  113. data/lib/bundler/plugin/index.rb +4 -1
  114. data/lib/bundler/plugin/installer/git.rb +0 -4
  115. data/lib/bundler/plugin/installer/rubygems.rb +0 -4
  116. data/lib/bundler/plugin/installer.rb +10 -10
  117. data/lib/bundler/plugin/source_list.rb +4 -0
  118. data/lib/bundler/plugin.rb +30 -8
  119. data/lib/bundler/process_lock.rb +1 -1
  120. data/lib/bundler/remote_specification.rb +10 -4
  121. data/lib/bundler/resolver/base.rb +50 -0
  122. data/lib/bundler/resolver/spec_group.rb +31 -73
  123. data/lib/bundler/resolver.rb +193 -292
  124. data/lib/bundler/retry.rb +1 -1
  125. data/lib/bundler/ruby_dsl.rb +1 -1
  126. data/lib/bundler/ruby_version.rb +5 -18
  127. data/lib/bundler/rubygems_ext.rb +160 -26
  128. data/lib/bundler/rubygems_gem_installer.rb +86 -9
  129. data/lib/bundler/rubygems_integration.rb +46 -93
  130. data/lib/bundler/runtime.rb +18 -12
  131. data/lib/bundler/self_manager.rb +168 -0
  132. data/lib/bundler/settings.rb +98 -22
  133. data/lib/bundler/setup.rb +2 -2
  134. data/lib/bundler/shared_helpers.rb +15 -31
  135. data/lib/bundler/source/git/git_proxy.rb +8 -6
  136. data/lib/bundler/source/git.rb +29 -13
  137. data/lib/bundler/source/metadata.rb +3 -7
  138. data/lib/bundler/source/path/installer.rb +1 -1
  139. data/lib/bundler/source/path.rb +3 -1
  140. data/lib/bundler/source/rubygems.rb +199 -182
  141. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  142. data/lib/bundler/source.rb +24 -4
  143. data/lib/bundler/source_list.rb +104 -60
  144. data/lib/bundler/source_map.rb +71 -0
  145. data/lib/bundler/spec_set.rb +58 -52
  146. data/lib/bundler/stub_specification.rb +13 -3
  147. data/lib/bundler/templates/Executable +2 -4
  148. data/lib/bundler/templates/Executable.bundler +8 -8
  149. data/lib/bundler/templates/Executable.standalone +2 -4
  150. data/lib/bundler/templates/Gemfile +0 -2
  151. data/lib/bundler/templates/gems.rb +0 -3
  152. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  153. data/lib/bundler/templates/newgem/README.md.tt +8 -12
  154. data/lib/bundler/templates/newgem/Rakefile.tt +15 -2
  155. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +16 -7
  156. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +5 -4
  157. data/lib/bundler/templates/newgem/newgem.gemspec.tt +19 -17
  158. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  159. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  160. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  161. data/lib/bundler/ui/shell.rb +1 -1
  162. data/lib/bundler/vendor/.document +1 -0
  163. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  164. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  165. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  166. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  167. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  168. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  169. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  170. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +3 -3
  171. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +32 -26
  172. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  173. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -1
  174. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  175. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  176. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
  177. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  178. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  179. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  180. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  181. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  182. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +22 -4
  183. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  184. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  185. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  186. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +1 -1
  187. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  188. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  189. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  190. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  191. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  192. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  193. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  194. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  195. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  196. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  197. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  198. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  199. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  200. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  201. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  202. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  203. data/lib/bundler/vendored_tsort.rb +4 -0
  204. data/lib/bundler/version.rb +1 -1
  205. data/lib/bundler/worker.rb +19 -4
  206. data/lib/bundler.rb +46 -39
  207. metadata +39 -12
  208. data/lib/bundler/dep_proxy.rb +0 -55
  209. data/lib/bundler/gemdeps.rb +0 -29
  210. data/lib/bundler/psyched_yaml.rb +0 -22
  211. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
@@ -12,22 +12,16 @@ module Bundler
12
12
  def setup(*groups)
13
13
  @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
14
14
 
15
- groups.map!(&:to_sym)
16
-
17
15
  # Has to happen first
18
16
  clean_load_path
19
17
 
20
- specs = groups.any? ? @definition.specs_for(groups) : requested_specs
18
+ specs = @definition.specs_for(groups)
21
19
 
22
20
  SharedHelpers.set_bundle_environment
23
21
  Bundler.rubygems.replace_entrypoints(specs)
24
22
 
25
23
  # Activate the specs
26
24
  load_paths = specs.map do |spec|
27
- unless spec.loaded_from
28
- raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
29
- end
30
-
31
25
  check_for_activated_spec!(spec)
32
26
 
33
27
  Bundler.rubygems.mark_loaded(spec)
@@ -106,7 +100,7 @@ module Bundler
106
100
 
107
101
  alias_method :gems, :specs
108
102
 
109
- def cache(custom_path = nil)
103
+ def cache(custom_path = nil, local = false)
110
104
  cache_path = Bundler.app_cache(custom_path)
111
105
  SharedHelpers.filesystem_access(cache_path) do |p|
112
106
  FileUtils.mkdir_p(p)
@@ -114,11 +108,23 @@ module Bundler
114
108
 
115
109
  Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
116
110
 
117
- specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
111
+ specs_to_cache = if Bundler.settings[:cache_all_platforms]
112
+ @definition.resolve.materialized_for_all_platforms
113
+ else
114
+ begin
115
+ specs
116
+ rescue GemNotFound
117
+ if local
118
+ Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
119
+ end
120
+
121
+ raise
122
+ end
123
+ end
124
+
118
125
  specs_to_cache.each do |spec|
119
126
  next if spec.name == "bundler"
120
127
  next if spec.source.is_a?(Source::Gemspec)
121
- spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
122
128
  spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
123
129
  end
124
130
 
@@ -258,7 +264,7 @@ module Bundler
258
264
 
259
265
  return if manuals.empty?
260
266
  Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
261
- ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
267
+ ENV["MANPATH"] ? ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR) : [""]
262
268
  ).uniq.join(File::PATH_SEPARATOR)
263
269
  end
264
270
 
@@ -284,7 +290,7 @@ module Bundler
284
290
  return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
285
291
  return if activated_spec.version == spec.version
286
292
 
287
- suggestion = if Bundler.rubygems.spec_default_gem?(activated_spec)
293
+ suggestion = if activated_spec.default_gem?
288
294
  "Since #{spec.name} is a default gem, you can either remove your dependency on it" \
289
295
  " or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
290
296
  else
@@ -0,0 +1,168 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ #
5
+ # This class handles installing and switching to the version of bundler needed
6
+ # by an application.
7
+ #
8
+ class SelfManager
9
+ def restart_with_locked_bundler_if_needed
10
+ return unless needs_switching? && installed?
11
+
12
+ restart_with(lockfile_version)
13
+ end
14
+
15
+ def install_locked_bundler_and_restart_with_it_if_needed
16
+ return unless needs_switching?
17
+
18
+ Bundler.ui.info \
19
+ "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
20
+ "Installing Bundler #{lockfile_version} and restarting using that version."
21
+
22
+ install_and_restart_with(lockfile_version)
23
+ end
24
+
25
+ def update_bundler_and_restart_with_it_if_needed(target)
26
+ return unless autoswitching_applies?
27
+
28
+ spec = resolve_update_version_from(target)
29
+ return unless spec
30
+
31
+ version = spec.version
32
+
33
+ Bundler.ui.info "Updating bundler to #{version}."
34
+
35
+ install(spec)
36
+
37
+ restart_with(version)
38
+ end
39
+
40
+ private
41
+
42
+ def install_and_restart_with(version)
43
+ requirement = Gem::Requirement.new(version)
44
+ spec = find_latest_matching_spec(requirement)
45
+
46
+ if spec.nil?
47
+ Bundler.ui.warn "Your lockfile is locked to a version of bundler (#{lockfile_version}) that doesn't exist at https://rubygems.org/. Going on using #{current_version}"
48
+ return
49
+ end
50
+
51
+ install(spec)
52
+ rescue StandardError => e
53
+ Bundler.ui.trace e
54
+ Bundler.ui.warn "There was an error installing the locked bundler version (#{lockfile_version}), rerun with the `--verbose` flag for more details. Going on using bundler #{current_version}."
55
+ else
56
+ restart_with(version)
57
+ end
58
+
59
+ def install(spec)
60
+ spec.source.install(spec)
61
+ end
62
+
63
+ def restart_with(version)
64
+ configured_gem_home = ENV["GEM_HOME"]
65
+ configured_gem_path = ENV["GEM_PATH"]
66
+
67
+ cmd = [$PROGRAM_NAME, *ARGV]
68
+ cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
69
+
70
+ Bundler.with_original_env do
71
+ Kernel.exec(
72
+ { "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => version.to_s },
73
+ *cmd
74
+ )
75
+ end
76
+ end
77
+
78
+ def needs_switching?
79
+ autoswitching_applies? &&
80
+ released?(lockfile_version) &&
81
+ !running?(lockfile_version) &&
82
+ !updating?
83
+ end
84
+
85
+ def autoswitching_applies?
86
+ ENV["BUNDLER_VERSION"].nil? &&
87
+ Bundler.rubygems.supports_bundler_trampolining? &&
88
+ SharedHelpers.in_bundle? &&
89
+ lockfile_version
90
+ end
91
+
92
+ def resolve_update_version_from(target)
93
+ requirement = Gem::Requirement.new(target)
94
+ update_candidate = find_latest_matching_spec(requirement)
95
+
96
+ if update_candidate.nil?
97
+ raise InvalidOption, "The `bundle update --bundler` target version (#{target}) does not exist"
98
+ end
99
+
100
+ resolved_version = update_candidate.version
101
+ needs_update = requirement.specific? ? !running?(resolved_version) : running_older_than?(resolved_version)
102
+
103
+ return unless needs_update
104
+
105
+ update_candidate
106
+ end
107
+
108
+ def local_specs
109
+ @local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true).specs.select {|spec| spec.name == "bundler" }
110
+ end
111
+
112
+ def remote_specs
113
+ @remote_specs ||= begin
114
+ source = Bundler::Source::Rubygems.new("remotes" => "https://rubygems.org")
115
+ source.remote!
116
+ source.add_dependency_names("bundler")
117
+ source.specs
118
+ end
119
+ end
120
+
121
+ def find_latest_matching_spec(requirement)
122
+ local_result = find_latest_matching_spec_from_collection(local_specs, requirement)
123
+ return local_result if local_result && requirement.specific?
124
+
125
+ remote_result = find_latest_matching_spec_from_collection(remote_specs, requirement)
126
+ return remote_result if local_result.nil?
127
+
128
+ [local_result, remote_result].max
129
+ end
130
+
131
+ def find_latest_matching_spec_from_collection(specs, requirement)
132
+ specs.sort.reverse_each.find {|spec| requirement.satisfied_by?(spec.version) }
133
+ end
134
+
135
+ def running?(version)
136
+ version == current_version
137
+ end
138
+
139
+ def running_older_than?(version)
140
+ current_version < version
141
+ end
142
+
143
+ def released?(version)
144
+ !version.to_s.end_with?(".dev")
145
+ end
146
+
147
+ def updating?
148
+ "update".start_with?(ARGV.first || " ") && ARGV[1..-1].any? {|a| a.start_with?("--bundler") }
149
+ end
150
+
151
+ def installed?
152
+ Bundler.configure
153
+
154
+ Bundler.rubygems.find_bundler(lockfile_version.to_s)
155
+ end
156
+
157
+ def current_version
158
+ @current_version ||= Gem::Version.new(Bundler::VERSION)
159
+ end
160
+
161
+ def lockfile_version
162
+ return @lockfile_version if defined?(@lockfile_version)
163
+
164
+ parsed_version = Bundler::LockfileParser.bundled_with
165
+ @lockfile_version = parsed_version ? Gem::Version.new(parsed_version) : nil
166
+ end
167
+ end
168
+ end
@@ -13,27 +13,28 @@ module Bundler
13
13
  auto_install
14
14
  cache_all
15
15
  cache_all_platforms
16
+ clean
16
17
  default_install_uses_path
17
18
  deployment
18
- deployment_means_frozen
19
19
  disable_checksum_validation
20
20
  disable_exec_load
21
21
  disable_local_branch_check
22
22
  disable_local_revision_check
23
- disable_multisource
24
23
  disable_shared_gems
25
24
  disable_version_check
26
25
  force_ruby_platform
27
26
  forget_cli_options
28
27
  frozen
28
+ gem.changelog
29
29
  gem.coc
30
30
  gem.mit
31
+ git.allow_insecure
31
32
  global_gem_cache
32
33
  ignore_messages
33
34
  init_gems_rb
35
+ inline
34
36
  no_install
35
37
  no_prune
36
- only_update_to_newer_versions
37
38
  path_relative_to_cwd
38
39
  path.system
39
40
  plugins
@@ -43,9 +44,7 @@ module Bundler
43
44
  silence_deprecations
44
45
  silence_root_warning
45
46
  suppress_install_using_messages
46
- unlock_source_unlocks_spec
47
47
  update_requires_all_flag
48
- use_gem_version_promoter_for_major_updates
49
48
  ].freeze
50
49
 
51
50
  NUMBER_KEYS = %w[
@@ -57,10 +56,27 @@ module Bundler
57
56
  ].freeze
58
57
 
59
58
  ARRAY_KEYS = %w[
59
+ only
60
60
  with
61
61
  without
62
62
  ].freeze
63
63
 
64
+ STRING_KEYS = %w[
65
+ bin
66
+ cache_path
67
+ console
68
+ gem.ci
69
+ gem.github_username
70
+ gem.linter
71
+ gem.rubocop
72
+ gem.test
73
+ gemfile
74
+ path
75
+ shebang
76
+ system_bindir
77
+ trust-policy
78
+ ].freeze
79
+
64
80
  DEFAULT_CONFIG = {
65
81
  "BUNDLE_SILENCE_DEPRECATIONS" => false,
66
82
  "BUNDLE_DISABLE_VERSION_CHECK" => true,
@@ -126,8 +142,8 @@ module Bundler
126
142
  keys = @temporary.keys | @global_config.keys | @local_config.keys | @env_config.keys
127
143
 
128
144
  keys.map do |key|
129
- key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase
130
- end
145
+ key.sub(/^BUNDLE_/, "").gsub(/___/, "-").gsub(/__/, ".").downcase
146
+ end.sort
131
147
  end
132
148
 
133
149
  def local_overrides
@@ -173,29 +189,37 @@ module Bundler
173
189
  locations = []
174
190
 
175
191
  if value = @temporary[key]
176
- locations << "Set for the current command: #{converted_value(value, exposed_key).inspect}"
192
+ locations << "Set for the current command: #{printable_value(value, exposed_key).inspect}"
177
193
  end
178
194
 
179
195
  if value = @local_config[key]
180
- locations << "Set for your local app (#{local_config_file}): #{converted_value(value, exposed_key).inspect}"
196
+ locations << "Set for your local app (#{local_config_file}): #{printable_value(value, exposed_key).inspect}"
181
197
  end
182
198
 
183
199
  if value = @env_config[key]
184
- locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}"
200
+ locations << "Set via #{key}: #{printable_value(value, exposed_key).inspect}"
185
201
  end
186
202
 
187
203
  if value = @global_config[key]
188
- locations << "Set for the current user (#{global_config_file}): #{converted_value(value, exposed_key).inspect}"
204
+ locations << "Set for the current user (#{global_config_file}): #{printable_value(value, exposed_key).inspect}"
189
205
  end
190
206
 
191
207
  return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
192
208
  locations
193
209
  end
194
210
 
211
+ def processor_count
212
+ require "etc"
213
+ Etc.nprocessors
214
+ rescue StandardError
215
+ 1
216
+ end
217
+
195
218
  # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
196
219
  def path
197
220
  configs.each do |_level, settings|
198
221
  path = value_for("path", settings)
222
+ path = "vendor/bundle" if value_for("deployment", settings) && path.nil?
199
223
  path_system = value_for("path.system", settings)
200
224
  disabled_shared_gems = value_for("disable_shared_gems", settings)
201
225
  next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
@@ -277,9 +301,7 @@ module Bundler
277
301
  end
278
302
 
279
303
  def key_for(key)
280
- key = Settings.normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
281
- key = key.to_s.gsub(".", "__").upcase
282
- "BUNDLE_#{key}"
304
+ self.class.key_for(key)
283
305
  end
284
306
 
285
307
  private
@@ -314,6 +336,10 @@ module Bundler
314
336
  BOOL_KEYS.include?(name.to_s) || BOOL_KEYS.include?(parent_setting_for(name.to_s))
315
337
  end
316
338
 
339
+ def is_string(name)
340
+ STRING_KEYS.include?(name.to_s) || name.to_s.start_with?("local.") || name.to_s.start_with?("mirror.") || name.to_s.start_with?("build.")
341
+ end
342
+
317
343
  def to_bool(value)
318
344
  case value
319
345
  when nil, /\A(false|f|no|n|0|)\z/i, false
@@ -331,9 +357,17 @@ module Bundler
331
357
  ARRAY_KEYS.include?(key.to_s)
332
358
  end
333
359
 
360
+ def is_credential(key)
361
+ key == "gem.push_key"
362
+ end
363
+
364
+ def is_userinfo(value)
365
+ value.include?(":")
366
+ end
367
+
334
368
  def to_array(value)
335
369
  return [] unless value
336
- value.split(":").map(&:to_sym)
370
+ value.tr(" ", ":").split(":").map(&:to_sym)
337
371
  end
338
372
 
339
373
  def array_to_s(array)
@@ -377,15 +411,38 @@ module Bundler
377
411
  end
378
412
  end
379
413
 
414
+ def printable_value(value, key)
415
+ converted = converted_value(value, key)
416
+ return converted unless converted.is_a?(String)
417
+
418
+ if is_string(key)
419
+ converted
420
+ elsif is_credential(key)
421
+ "[REDACTED]"
422
+ elsif is_userinfo(converted)
423
+ username, pass = converted.split(":", 2)
424
+
425
+ if pass == "x-oauth-basic"
426
+ username = "[REDACTED]"
427
+ else
428
+ pass = "[REDACTED]"
429
+ end
430
+
431
+ [username, pass].join(":")
432
+ else
433
+ converted
434
+ end
435
+ end
436
+
380
437
  def global_config_file
381
438
  if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
382
439
  Pathname.new(ENV["BUNDLE_CONFIG"])
383
- else
384
- begin
385
- Bundler.user_bundle_path("config")
386
- rescue PermissionError, GenericSystemCallError
387
- nil
388
- end
440
+ elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty?
441
+ Pathname.new(ENV["BUNDLE_USER_CONFIG"])
442
+ elsif ENV["BUNDLE_USER_HOME"] && !ENV["BUNDLE_USER_HOME"].empty?
443
+ Pathname.new(ENV["BUNDLE_USER_HOME"]).join("config")
444
+ elsif Bundler.rubygems.user_home && !Bundler.rubygems.user_home.empty?
445
+ Pathname.new(Bundler.rubygems.user_home).join(".bundle/config")
389
446
  end
390
447
  end
391
448
 
@@ -399,7 +456,20 @@ module Bundler
399
456
  valid_file = file.exist? && !file.size.zero?
400
457
  return {} unless valid_file
401
458
  require_relative "yaml_serializer"
402
- YAMLSerializer.load file.read
459
+ YAMLSerializer.load(file.read).inject({}) do |config, (k, v)|
460
+ new_k = k
461
+
462
+ if k.include?("-")
463
+ Bundler.ui.warn "Your #{file} config includes `#{k}`, which contains the dash character (`-`).\n" \
464
+ "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n" \
465
+ "Please edit #{file} and replace any dashes in configuration keys with a triple underscore (`___`)."
466
+
467
+ new_k = k.gsub("-", "___")
468
+ end
469
+
470
+ config[new_k] = v
471
+ config
472
+ end
403
473
  end
404
474
  end
405
475
 
@@ -416,6 +486,12 @@ module Bundler
416
486
  \z
417
487
  /ix.freeze
418
488
 
489
+ def self.key_for(key)
490
+ key = normalize_uri(key).to_s if key.is_a?(String) && key.start_with?("http", "mirror.http")
491
+ key = key.to_s.gsub(".", "__").gsub("-", "___").upcase
492
+ "BUNDLE_#{key}"
493
+ end
494
+
419
495
  # TODO: duplicates Rubygems#normalize_uri
420
496
  # TODO: is this the correct place to validate mirror URIs?
421
497
  def self.normalize_uri(uri)
data/lib/bundler/setup.rb CHANGED
@@ -9,10 +9,10 @@ if Bundler::SharedHelpers.in_bundle?
9
9
  begin
10
10
  Bundler.ui.silence { Bundler.setup }
11
11
  rescue Bundler::BundlerError => e
12
- Bundler.ui.warn "\e[31m#{e.message}\e[0m"
12
+ Bundler.ui.error e.message
13
13
  Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
14
14
  if e.is_a?(Bundler::GemNotFound)
15
- Bundler.ui.warn "\e[33mRun `bundle install` to install missing gems.\e[0m"
15
+ Bundler.ui.warn "Run `bundle install` to install missing gems."
16
16
  end
17
17
  exit e.status_code
18
18
  end
@@ -13,13 +13,13 @@ module Bundler
13
13
  def root
14
14
  gemfile = find_gemfile
15
15
  raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
16
- Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
16
+ Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
17
17
  end
18
18
 
19
19
  def default_gemfile
20
20
  gemfile = find_gemfile
21
21
  raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
22
- Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
22
+ Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
23
23
  end
24
24
 
25
25
  def default_lockfile
@@ -28,7 +28,7 @@ module Bundler
28
28
  case gemfile.basename.to_s
29
29
  when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
30
30
  else Pathname.new("#{gemfile}.lock")
31
- end.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
31
+ end.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
32
32
  end
33
33
 
34
34
  def default_bundle_dir
@@ -100,7 +100,7 @@ module Bundler
100
100
  #
101
101
  # @see {Bundler::PermissionError}
102
102
  def filesystem_access(path, action = :write, &block)
103
- yield(path.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" })
103
+ yield(path.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" })
104
104
  rescue Errno::EACCES
105
105
  raise PermissionError.new(path, action)
106
106
  rescue Errno::EAGAIN
@@ -109,7 +109,7 @@ module Bundler
109
109
  raise VirtualProtocolError.new
110
110
  rescue Errno::ENOSPC
111
111
  raise NoSpaceOnDeviceError.new(path, action)
112
- rescue *[const_get_safely(:ENOTSUP, Errno)].compact
112
+ rescue Errno::ENOTSUP
113
113
  raise OperationNotSupportedError.new(path, action)
114
114
  rescue Errno::EEXIST, Errno::ENOENT
115
115
  raise
@@ -117,13 +117,6 @@ module Bundler
117
117
  raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
118
118
  end
119
119
 
120
- def const_get_safely(constant_name, namespace)
121
- const_in_namespace = namespace.constants.include?(constant_name.to_s) ||
122
- namespace.constants.include?(constant_name.to_sym)
123
- return nil unless const_in_namespace
124
- namespace.const_get(constant_name)
125
- end
126
-
127
120
  def major_deprecation(major_version, message, print_caller_location: false)
128
121
  if print_caller_location
129
122
  caller_location = caller_locations(2, 2).first
@@ -148,17 +141,10 @@ module Bundler
148
141
  end
149
142
  return unless multiple_gemfiles
150
143
  message = "Multiple gemfiles (gems.rb and Gemfile) detected. " \
151
- "Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
144
+ "Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.locked."
152
145
  Bundler.ui.warn message
153
146
  end
154
147
 
155
- def trap(signal, override = false, &block)
156
- prior = Signal.trap(signal) do
157
- block.call
158
- prior.call unless override
159
- end
160
- end
161
-
162
148
  def ensure_same_dependencies(spec, old_deps, new_deps)
163
149
  new_deps = new_deps.reject {|d| d.type == :development }
164
150
  old_deps = old_deps.reject {|d| d.type == :development }
@@ -177,7 +163,7 @@ module Bundler
177
163
  "\nEither installing with `--full-index` or running `bundle update #{spec.name}` should fix the problem."
178
164
  end
179
165
 
180
- def pretty_dependency(dep, print_source = false)
166
+ def pretty_dependency(dep)
181
167
  msg = String.new(dep.name)
182
168
  msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
183
169
 
@@ -186,7 +172,6 @@ module Bundler
186
172
  msg << " " << platform_string if !platform_string.empty? && platform_string != Gem::Platform::RUBY
187
173
  end
188
174
 
189
- msg << " from the `#{dep.source}` source" if print_source && dep.source
190
175
  msg
191
176
  end
192
177
 
@@ -250,10 +235,10 @@ module Bundler
250
235
 
251
236
  def search_up(*names)
252
237
  previous = nil
253
- current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" }
238
+ current = File.expand_path(SharedHelpers.pwd).tap {|x| x.untaint if RUBY_VERSION < "2.7" }
254
239
 
255
240
  until !File.directory?(current) || current == previous
256
- if ENV["BUNDLE_SPEC_RUN"]
241
+ if ENV["BUNDLER_SPEC_RUN"]
257
242
  # avoid stepping above the tmp directory when testing
258
243
  gemspec = if ENV["GEM_COMMAND"]
259
244
  # for Ruby Core
@@ -288,10 +273,10 @@ module Bundler
288
273
 
289
274
  def set_bundle_variables
290
275
  # bundler exe & lib folders have same root folder, typical gem installation
291
- exe_file = File.expand_path("../../../exe/bundle", __FILE__)
276
+ exe_file = File.expand_path("../../exe/bundle", __dir__)
292
277
 
293
278
  # for Ruby core repository testing
294
- exe_file = File.expand_path("../../../libexec/bundle", __FILE__) unless File.exist?(exe_file)
279
+ exe_file = File.expand_path("../../libexec/bundle", __dir__) unless File.exist?(exe_file)
295
280
 
296
281
  # bundler is a default gem, exe path is separate
297
282
  exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
@@ -323,16 +308,15 @@ module Bundler
323
308
  end
324
309
 
325
310
  def bundler_ruby_lib
326
- resolve_path File.expand_path("../..", __FILE__)
311
+ File.expand_path("..", __dir__)
327
312
  end
328
313
 
329
314
  def clean_load_path
330
- bundler_lib = bundler_ruby_lib
331
-
332
315
  loaded_gem_paths = Bundler.rubygems.loaded_gem_paths
333
316
 
334
317
  $LOAD_PATH.reject! do |p|
335
- next if resolve_path(p).start_with?(bundler_lib)
318
+ resolved_path = resolve_path(p)
319
+ next if $LOADED_FEATURES.any? {|lf| lf.start_with?(resolved_path) }
336
320
  loaded_gem_paths.delete(p)
337
321
  end
338
322
  $LOAD_PATH.uniq!
@@ -340,7 +324,7 @@ module Bundler
340
324
 
341
325
  def resolve_path(path)
342
326
  expanded = File.expand_path(path)
343
- return expanded unless File.respond_to?(:realpath) && File.exist?(expanded)
327
+ return expanded unless File.exist?(expanded)
344
328
 
345
329
  File.realpath(expanded)
346
330
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class Source
7
5
  class Git
@@ -58,7 +56,6 @@ module Bundler
58
56
  @ref = ref
59
57
  @revision = revision
60
58
  @git = git
61
- raise GitNotInstalledError.new if allow? && !Bundler.git_present?
62
59
  end
63
60
 
64
61
  def revision
@@ -98,12 +95,12 @@ module Bundler
98
95
  SharedHelpers.filesystem_access(path.dirname) do |p|
99
96
  FileUtils.mkdir_p(p)
100
97
  end
101
- git_retry "clone", configured_uri, path.to_s, "--bare", "--no-hardlinks", "--quiet"
98
+ git_retry "clone", "--bare", "--no-hardlinks", "--quiet", "--", configured_uri, path.to_s
102
99
  return unless extra_ref
103
100
  end
104
101
 
105
102
  with_path do
106
- git_retry(*["fetch", "--force", "--quiet", "--tags", configured_uri, "refs/heads/*:refs/heads/*", extra_ref].compact, :dir => path)
103
+ git_retry(*["fetch", "--force", "--quiet", "--tags", "--", configured_uri, "refs/heads/*:refs/heads/*", extra_ref].compact, :dir => path)
107
104
  end
108
105
  end
109
106
 
@@ -210,7 +207,11 @@ module Bundler
210
207
  end
211
208
 
212
209
  def allow?
213
- @git ? @git.allow_git_ops? : true
210
+ allowed = @git ? @git.allow_git_ops? : true
211
+
212
+ raise GitNotInstalledError.new if allowed && !Bundler.git_present?
213
+
214
+ allowed
214
215
  end
215
216
 
216
217
  def with_path(&blk)
@@ -224,6 +225,7 @@ module Bundler
224
225
  end
225
226
 
226
227
  def check_allowed(command)
228
+ require "shellwords"
227
229
  command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
228
230
  raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
229
231
  command_with_no_credentials