rubygems-update 3.5.22 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +91 -0
  3. data/Manifest.txt +23 -16
  4. data/README.md +14 -9
  5. data/bundler/CHANGELOG.md +83 -0
  6. data/bundler/bundler.gemspec +2 -2
  7. data/bundler/lib/bundler/build_metadata.rb +2 -2
  8. data/bundler/lib/bundler/cli/add.rb +2 -0
  9. data/bundler/lib/bundler/cli/check.rb +2 -2
  10. data/bundler/lib/bundler/cli/console.rb +0 -4
  11. data/bundler/lib/bundler/cli/doctor.rb +4 -4
  12. data/bundler/lib/bundler/cli/exec.rb +1 -0
  13. data/bundler/lib/bundler/cli/gem.rb +1 -1
  14. data/bundler/lib/bundler/cli/info.rb +2 -2
  15. data/bundler/lib/bundler/cli/inject.rb +1 -1
  16. data/bundler/lib/bundler/cli/install.rb +4 -0
  17. data/bundler/lib/bundler/cli/lock.rb +20 -1
  18. data/bundler/lib/bundler/cli/pristine.rb +1 -1
  19. data/bundler/lib/bundler/cli/show.rb +2 -2
  20. data/bundler/lib/bundler/cli.rb +23 -53
  21. data/bundler/lib/bundler/compact_index_client/cache_file.rb +0 -5
  22. data/bundler/lib/bundler/compact_index_client/updater.rb +0 -11
  23. data/bundler/lib/bundler/definition.rb +143 -76
  24. data/bundler/lib/bundler/dependency.rb +1 -1
  25. data/bundler/lib/bundler/dsl.rb +33 -28
  26. data/bundler/lib/bundler/endpoint_specification.rb +10 -1
  27. data/bundler/lib/bundler/errors.rb +10 -0
  28. data/bundler/lib/bundler/feature_flag.rb +1 -0
  29. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  30. data/bundler/lib/bundler/fetcher.rb +10 -3
  31. data/bundler/lib/bundler/gem_helpers.rb +21 -5
  32. data/bundler/lib/bundler/injector.rb +2 -2
  33. data/bundler/lib/bundler/inline.rb +12 -8
  34. data/bundler/lib/bundler/installer/standalone.rb +2 -2
  35. data/bundler/lib/bundler/installer.rb +4 -38
  36. data/bundler/lib/bundler/lazy_specification.rb +74 -26
  37. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  38. data/bundler/lib/bundler/lockfile_parser.rb +9 -1
  39. data/bundler/lib/bundler/man/bundle-add.1 +17 -11
  40. data/bundler/lib/bundler/man/bundle-add.1.ronn +16 -10
  41. data/bundler/lib/bundler/man/bundle-binstubs.1 +7 -4
  42. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  43. data/bundler/lib/bundler/man/bundle-cache.1 +30 -2
  44. data/bundler/lib/bundler/man/bundle-cache.1.ronn +31 -2
  45. data/bundler/lib/bundler/man/bundle-check.1 +3 -3
  46. data/bundler/lib/bundler/man/bundle-check.1.ronn +4 -2
  47. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  48. data/bundler/lib/bundler/man/bundle-config.1 +3 -5
  49. data/bundler/lib/bundler/man/bundle-config.1.ronn +2 -7
  50. data/bundler/lib/bundler/man/bundle-console.1 +2 -4
  51. data/bundler/lib/bundler/man/bundle-console.1.ronn +2 -7
  52. data/bundler/lib/bundler/man/bundle-doctor.1 +2 -2
  53. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  54. data/bundler/lib/bundler/man/bundle-env.1 +9 -0
  55. data/bundler/lib/bundler/man/bundle-env.1.ronn +10 -0
  56. data/bundler/lib/bundler/man/bundle-exec.1 +5 -2
  57. data/bundler/lib/bundler/man/bundle-exec.1.ronn +4 -1
  58. data/bundler/lib/bundler/man/bundle-fund.1 +22 -0
  59. data/bundler/lib/bundler/man/bundle-fund.1.ronn +25 -0
  60. data/bundler/lib/bundler/man/bundle-gem.1 +17 -5
  61. data/bundler/lib/bundler/man/bundle-gem.1.ronn +27 -6
  62. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-info.1 +5 -2
  64. data/bundler/lib/bundler/man/bundle-info.1.ronn +6 -2
  65. data/bundler/lib/bundler/man/bundle-init.1 +3 -3
  66. data/bundler/lib/bundler/man/bundle-init.1.ronn +3 -2
  67. data/bundler/lib/bundler/man/bundle-inject.1 +10 -2
  68. data/bundler/lib/bundler/man/bundle-inject.1.ronn +9 -1
  69. data/bundler/lib/bundler/man/bundle-install.1 +15 -12
  70. data/bundler/lib/bundler/man/bundle-install.1.ronn +22 -18
  71. data/bundler/lib/bundler/man/bundle-issue.1 +45 -0
  72. data/bundler/lib/bundler/man/bundle-issue.1.ronn +37 -0
  73. data/bundler/lib/bundler/man/bundle-licenses.1 +9 -0
  74. data/bundler/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  75. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  76. data/bundler/lib/bundler/man/bundle-list.1.ronn +4 -1
  77. data/bundler/lib/bundler/man/bundle-lock.1 +21 -6
  78. data/bundler/lib/bundler/man/bundle-lock.1.ronn +25 -4
  79. data/bundler/lib/bundler/man/bundle-open.1 +2 -2
  80. data/bundler/lib/bundler/man/bundle-open.1.ronn +2 -1
  81. data/bundler/lib/bundler/man/bundle-outdated.1 +8 -5
  82. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +8 -4
  83. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  84. data/bundler/lib/bundler/man/bundle-plugin.1 +1 -1
  85. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  86. data/bundler/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  87. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  88. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -1
  89. data/bundler/lib/bundler/man/bundle-show.1 +5 -2
  90. data/bundler/lib/bundler/man/bundle-show.1.ronn +4 -0
  91. data/bundler/lib/bundler/man/bundle-update.1 +13 -7
  92. data/bundler/lib/bundler/man/bundle-update.1.ronn +14 -6
  93. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  94. data/bundler/lib/bundler/man/bundle-viz.1 +4 -4
  95. data/bundler/lib/bundler/man/bundle-viz.1.ronn +7 -3
  96. data/bundler/lib/bundler/man/bundle.1 +1 -1
  97. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  98. data/bundler/lib/bundler/man/index.txt +4 -0
  99. data/bundler/lib/bundler/materialization.rb +59 -0
  100. data/bundler/lib/bundler/plugin/events.rb +24 -0
  101. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  102. data/bundler/lib/bundler/plugin.rb +20 -1
  103. data/bundler/lib/bundler/process_lock.rb +10 -14
  104. data/bundler/lib/bundler/remote_specification.rb +6 -1
  105. data/bundler/lib/bundler/resolver/base.rb +6 -6
  106. data/bundler/lib/bundler/resolver/candidate.rb +2 -2
  107. data/bundler/lib/bundler/resolver/spec_group.rb +4 -3
  108. data/bundler/lib/bundler/resolver.rb +5 -5
  109. data/bundler/lib/bundler/rubygems_ext.rb +30 -27
  110. data/bundler/lib/bundler/rubygems_gem_installer.rb +3 -2
  111. data/bundler/lib/bundler/rubygems_integration.rb +23 -40
  112. data/bundler/lib/bundler/runtime.rb +27 -7
  113. data/bundler/lib/bundler/self_manager.rb +2 -3
  114. data/bundler/lib/bundler/settings.rb +6 -1
  115. data/bundler/lib/bundler/shared_helpers.rb +29 -17
  116. data/bundler/lib/bundler/source/git/git_proxy.rb +0 -6
  117. data/bundler/lib/bundler/source/git.rb +56 -31
  118. data/bundler/lib/bundler/source/metadata.rb +2 -3
  119. data/bundler/lib/bundler/source/path.rb +2 -2
  120. data/bundler/lib/bundler/source_list.rb +1 -1
  121. data/bundler/lib/bundler/spec_set.rb +81 -56
  122. data/bundler/lib/bundler/stub_specification.rb +8 -0
  123. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +0 -3
  124. data/bundler/lib/bundler/templates/newgem/README.md.tt +1 -1
  125. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +15 -15
  126. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -4
  127. data/bundler/lib/bundler/uri_credentials_filter.rb +1 -1
  128. data/bundler/lib/bundler/vendor/fileutils/COPYING +56 -0
  129. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +15 -13
  130. data/bundler/lib/bundler/vendor/securerandom/COPYING +56 -0
  131. data/bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb +5 -5
  132. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +3 -5
  133. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +11 -0
  134. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +1 -4
  135. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +2 -2
  136. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +2 -1
  137. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +9 -9
  138. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  139. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +5 -21
  140. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  141. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  142. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +11 -0
  143. data/bundler/lib/bundler/vendor/uri/COPYING +56 -0
  144. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +37 -16
  145. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +3 -3
  146. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +1 -1
  147. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +16 -26
  148. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +2 -2
  149. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  150. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  151. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  152. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +9 -9
  153. data/bundler/lib/bundler/vendored_securerandom.rb +0 -2
  154. data/bundler/lib/bundler/version.rb +1 -1
  155. data/bundler/lib/bundler.rb +38 -14
  156. data/{CONTRIBUTING.md → doc/rubygems/CONTRIBUTING.md} +9 -9
  157. data/{POLICIES.md → doc/rubygems/POLICIES.md} +11 -11
  158. data/lib/rubygems/basic_specification.rb +5 -4
  159. data/lib/rubygems/commands/cleanup_command.rb +2 -2
  160. data/lib/rubygems/commands/contents_command.rb +4 -4
  161. data/lib/rubygems/commands/exec_command.rb +3 -0
  162. data/lib/rubygems/commands/pristine_command.rb +2 -2
  163. data/lib/rubygems/commands/push_command.rb +29 -5
  164. data/lib/rubygems/commands/rdoc_command.rb +2 -2
  165. data/lib/rubygems/commands/rebuild_command.rb +0 -2
  166. data/lib/rubygems/commands/setup_command.rb +7 -16
  167. data/lib/rubygems/commands/unpack_command.rb +0 -6
  168. data/lib/rubygems/commands/update_command.rb +2 -8
  169. data/lib/rubygems/config_file.rb +12 -0
  170. data/lib/rubygems/core_ext/kernel_warn.rb +2 -6
  171. data/lib/rubygems/defaults.rb +1 -1
  172. data/lib/rubygems/exceptions.rb +0 -6
  173. data/lib/rubygems/ext/builder.rb +6 -4
  174. data/lib/rubygems/ext/cargo_builder.rb +7 -4
  175. data/lib/rubygems/ext/cmake_builder.rb +7 -2
  176. data/lib/rubygems/ext/configure_builder.rb +7 -2
  177. data/lib/rubygems/ext/ext_conf_builder.rb +9 -5
  178. data/lib/rubygems/ext/rake_builder.rb +6 -1
  179. data/lib/rubygems/gem_runner.rb +9 -0
  180. data/lib/rubygems/gemcutter_utilities.rb +8 -2
  181. data/lib/rubygems/install_update_options.rb +5 -0
  182. data/lib/rubygems/installer.rb +8 -9
  183. data/lib/rubygems/package/tar_header.rb +11 -0
  184. data/lib/rubygems/package/tar_reader/entry.rb +1 -5
  185. data/lib/rubygems/platform.rb +4 -3
  186. data/lib/rubygems/psych_tree.rb +4 -0
  187. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  188. data/lib/rubygems/requirement.rb +0 -4
  189. data/lib/rubygems/resolver/composed_set.rb +3 -3
  190. data/lib/rubygems/resolver/git_set.rb +0 -1
  191. data/lib/rubygems/resolver/index_set.rb +2 -2
  192. data/lib/rubygems/resolver.rb +3 -3
  193. data/lib/rubygems/source/git.rb +13 -10
  194. data/lib/rubygems/spec_fetcher.rb +46 -7
  195. data/lib/rubygems/specification.rb +38 -32
  196. data/lib/rubygems/target_rbconfig.rb +50 -0
  197. data/lib/rubygems/uri.rb +1 -1
  198. data/lib/rubygems/util/licenses.rb +10 -1
  199. data/lib/rubygems/vendor/net-http/COPYING +56 -0
  200. data/lib/rubygems/vendor/net-http/lib/net/http/header.rb +1 -1
  201. data/lib/rubygems/vendor/net-http/lib/net/http/requests.rb +5 -0
  202. data/lib/rubygems/vendor/net-http/lib/net/http.rb +120 -36
  203. data/lib/rubygems/vendor/optparse/lib/optparse/ac.rb +16 -0
  204. data/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb +8 -3
  205. data/lib/rubygems/vendor/optparse/lib/optparse/version.rb +9 -0
  206. data/lib/rubygems/vendor/optparse/lib/optparse.rb +147 -51
  207. data/lib/rubygems/vendor/resolv/COPYING +56 -0
  208. data/lib/rubygems/vendor/resolv/lib/resolv.rb +50 -37
  209. data/lib/rubygems/vendor/securerandom/COPYING +56 -0
  210. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +5 -5
  211. data/lib/rubygems/vendor/timeout/COPYING +56 -0
  212. data/lib/rubygems/vendor/timeout/lib/timeout.rb +5 -8
  213. data/lib/rubygems/vendor/uri/COPYING +56 -0
  214. data/lib/rubygems/vendor/uri/lib/uri/common.rb +37 -16
  215. data/lib/rubygems/vendor/uri/lib/uri/file.rb +3 -3
  216. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +1 -1
  217. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +16 -26
  218. data/lib/rubygems/vendor/uri/lib/uri/http.rb +2 -2
  219. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  220. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  221. data/lib/rubygems/vendor/uri/lib/uri/version.rb +1 -1
  222. data/lib/rubygems/vendor/uri/lib/uri.rb +9 -9
  223. data/lib/rubygems/vendored_securerandom.rb +0 -1
  224. data/lib/rubygems/version.rb +0 -4
  225. data/lib/rubygems.rb +30 -20
  226. data/rubygems-update.gemspec +5 -5
  227. data/setup.rb +1 -1
  228. metadata +36 -27
  229. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +0 -22
  230. data/bundler/lib/bundler/vendor/securerandom/LICENSE.txt +0 -22
  231. data/bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb +0 -373
  232. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +0 -22
  233. data/lib/rubygems/vendor/net-http/LICENSE.txt +0 -22
  234. data/lib/rubygems/vendor/net-http/lib/net/http/backward.rb +0 -40
  235. data/lib/rubygems/vendor/resolv/LICENSE.txt +0 -22
  236. data/lib/rubygems/vendor/securerandom/LICENSE.txt +0 -22
  237. data/lib/rubygems/vendor/securerandom/lib/random/formatter.rb +0 -373
  238. data/lib/rubygems/vendor/timeout/LICENSE.txt +0 -22
  239. data/lib/rubygems/vendor/uri/LICENSE.txt +0 -22
  240. /data/{MAINTAINERS.txt → doc/MAINTAINERS.txt} +0 -0
  241. /data/{bundler → doc/bundler}/UPGRADING.md +0 -0
  242. /data/{UPGRADING.md → doc/rubygems/UPGRADING.md} +0 -0
@@ -12,7 +12,7 @@ module Bundler
12
12
 
13
13
  attr_reader :name, :version, :platform
14
14
  attr_writer :dependencies
15
- attr_accessor :source, :remote
15
+ attr_accessor :source, :remote, :locked_platform
16
16
 
17
17
  def initialize(name, version, platform, spec_fetcher)
18
18
  @name = name
@@ -21,6 +21,11 @@ module Bundler
21
21
  @platform = Gem::Platform.new(platform)
22
22
  @spec_fetcher = spec_fetcher
23
23
  @dependencies = nil
24
+ @locked_platform = nil
25
+ end
26
+
27
+ def insecurely_materialized?
28
+ @locked_platform.to_s != @platform.to_s
24
29
  end
25
30
 
26
31
  # Needed before installs, since the arch matters then and quick
@@ -16,7 +16,7 @@ module Bundler
16
16
  hash[name] = Package.new(name, platforms, **options)
17
17
  end
18
18
 
19
- @requirements = dependencies.map do |dep|
19
+ @requirements = dependencies.filter_map do |dep|
20
20
  dep_platforms = dep.gem_platforms(platforms)
21
21
 
22
22
  # Dependencies scoped to external platforms are ignored
@@ -27,11 +27,7 @@ module Bundler
27
27
  @packages[name] = Package.new(name, dep_platforms, **options.merge(dependency: dep))
28
28
 
29
29
  dep
30
- end.compact
31
- end
32
-
33
- def specs_compatible_with(result)
34
- @base.specs_compatible_with(result)
30
+ end
35
31
  end
36
32
 
37
33
  def [](name)
@@ -107,6 +103,10 @@ module Bundler
107
103
  def build_base_requirements
108
104
  base_requirements = {}
109
105
  @base.each do |ls|
106
+ if ls.source_changed? && ls.source.specs.search(ls.name).empty?
107
+ raise GemNotFound, "Could not find gem '#{ls.name}' in #{ls.source}"
108
+ end
109
+
110
110
  req = Gem::Requirement.new(ls.version)
111
111
  base_requirements[ls.name] = req
112
112
  end
@@ -34,10 +34,10 @@ module Bundler
34
34
  @spec_group.dependencies
35
35
  end
36
36
 
37
- def to_specs(package)
37
+ def to_specs(package, most_specific_locked_platform)
38
38
  return [] if package.meta?
39
39
 
40
- @spec_group.to_specs(package.force_ruby_platform?)
40
+ @spec_group.to_specs(package.force_ruby_platform?, most_specific_locked_platform)
41
41
  end
42
42
 
43
43
  def prerelease?
@@ -25,10 +25,11 @@ module Bundler
25
25
  @source ||= exemplary_spec.source
26
26
  end
27
27
 
28
- def to_specs(force_ruby_platform)
28
+ def to_specs(force_ruby_platform, most_specific_locked_platform)
29
29
  @specs.map do |s|
30
30
  lazy_spec = LazySpecification.from_spec(s)
31
31
  lazy_spec.force_ruby_platform = force_ruby_platform
32
+ lazy_spec.most_specific_locked_platform = most_specific_locked_platform
32
33
  lazy_spec
33
34
  end
34
35
  end
@@ -38,9 +39,9 @@ module Bundler
38
39
  end
39
40
 
40
41
  def dependencies
41
- @dependencies ||= @specs.map do |spec|
42
+ @dependencies ||= @specs.flat_map do |spec|
42
43
  __dependencies(spec) + metadata_dependencies(spec)
43
- end.flatten.uniq.sort
44
+ end.uniq.sort
44
45
  end
45
46
 
46
47
  def ==(other)
@@ -15,10 +15,11 @@ module Bundler
15
15
 
16
16
  include GemHelpers
17
17
 
18
- def initialize(base, gem_version_promoter)
18
+ def initialize(base, gem_version_promoter, most_specific_locked_platform = nil)
19
19
  @source_requirements = base.source_requirements
20
20
  @base = base
21
21
  @gem_version_promoter = gem_version_promoter
22
+ @most_specific_locked_platform = most_specific_locked_platform
22
23
  end
23
24
 
24
25
  def start
@@ -79,8 +80,7 @@ module Bundler
79
80
  def solve_versions(root:, logger:)
80
81
  solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
81
82
  result = solver.solve
82
- resolved_specs = result.map {|package, version| version.to_specs(package) }.flatten
83
- resolved_specs |= @base.specs_compatible_with(SpecSet.new(resolved_specs))
83
+ result.flat_map {|package, version| version.to_specs(package, @most_specific_locked_platform) }
84
84
  rescue PubGrub::SolveFailure => e
85
85
  incompatibility = e.incompatibility
86
86
 
@@ -417,7 +417,7 @@ module Bundler
417
417
  end
418
418
 
419
419
  def prepare_dependencies(requirements, packages)
420
- to_dependency_hash(requirements, packages).map do |dep_package, dep_constraint|
420
+ to_dependency_hash(requirements, packages).filter_map do |dep_package, dep_constraint|
421
421
  name = dep_package.name
422
422
 
423
423
  next [dep_package, dep_constraint] if name == "bundler"
@@ -443,7 +443,7 @@ module Bundler
443
443
  next unless dep_package.current_platform?
444
444
 
445
445
  raise_not_found!(dep_package)
446
- end.compact.to_h
446
+ end.to_h
447
447
  end
448
448
 
449
449
  def select_sorted_versions(package, range)
@@ -79,14 +79,18 @@ module Gem
79
79
  include ::Bundler::MatchMetadata
80
80
  include ::Bundler::MatchPlatform
81
81
 
82
- attr_accessor :remote, :location, :relative_loaded_from
82
+ attr_accessor :remote, :relative_loaded_from
83
83
 
84
- remove_method :source
85
- attr_writer :source
86
- def source
87
- (defined?(@source) && @source) || Gem::Source::Installed.new
84
+ module AllowSettingSource
85
+ attr_writer :source
86
+
87
+ def source
88
+ (defined?(@source) && @source) || super
89
+ end
88
90
  end
89
91
 
92
+ prepend AllowSettingSource
93
+
90
94
  alias_method :rg_full_gem_path, :full_gem_path
91
95
  alias_method :rg_loaded_from, :loaded_from
92
96
 
@@ -122,7 +126,9 @@ module Gem
122
126
  end
123
127
  end
124
128
 
125
- remove_method :gem_dir
129
+ # Can be removed once RubyGems 3.5.21 support is dropped
130
+ remove_method :gem_dir if method_defined?(:gem_dir, false)
131
+
126
132
  def gem_dir
127
133
  full_gem_path
128
134
  end
@@ -144,6 +150,10 @@ module Gem
144
150
  end
145
151
  end
146
152
 
153
+ def insecurely_materialized?
154
+ false
155
+ end
156
+
147
157
  def groups
148
158
  @groups ||= []
149
159
  end
@@ -278,23 +288,6 @@ module Gem
278
288
  end
279
289
  end
280
290
 
281
- # Requirements using lambda operator differentiate trailing zeros since rubygems 3.2.6
282
- if Gem::Requirement.new("~> 2.0").hash == Gem::Requirement.new("~> 2.0.0").hash
283
- class Requirement
284
- module CorrectHashForLambdaOperator
285
- def hash
286
- if requirements.any? {|r| r.first == "~>" }
287
- requirements.map {|r| r.first == "~>" ? [r[0], r[1].to_s] : r }.sort.hash
288
- else
289
- super
290
- end
291
- end
292
- end
293
-
294
- prepend CorrectHashForLambdaOperator
295
- end
296
- end
297
-
298
291
  require "rubygems/platform"
299
292
 
300
293
  class Platform
@@ -344,10 +337,6 @@ module Gem
344
337
  without_gnu_nor_abi_modifiers
345
338
  end
346
339
  end
347
-
348
- if RUBY_ENGINE == "truffleruby" && !defined?(REUSE_AS_BINARY_ON_TRUFFLERUBY)
349
- REUSE_AS_BINARY_ON_TRUFFLERUBY = %w[libv8 libv8-node sorbet-static].freeze
350
- end
351
340
  end
352
341
 
353
342
  Platform.singleton_class.module_eval do
@@ -452,4 +441,18 @@ module Gem
452
441
  end
453
442
  end
454
443
  end
444
+
445
+ if Gem.rubygems_version < Gem::Version.new("3.6.0")
446
+ class Package; end
447
+ require "rubygems/package/tar_reader"
448
+ require "rubygems/package/tar_reader/entry"
449
+
450
+ module FixFullNameEncoding
451
+ def full_name
452
+ super.force_encoding(Encoding::UTF_8)
453
+ end
454
+ end
455
+
456
+ Package::TarReader::Entry.prepend(FixFullNameEncoding)
457
+ end
455
458
  end
@@ -23,7 +23,9 @@ module Bundler
23
23
  FileUtils.mkdir_p gem_dir, mode: 0o755
24
24
  end
25
25
 
26
- extract_files
26
+ SharedHelpers.filesystem_access(gem_dir, :write) do
27
+ extract_files
28
+ end
27
29
 
28
30
  build_extensions if spec.extensions.any?
29
31
  write_build_info_file
@@ -145,7 +147,6 @@ module Bundler
145
147
  SharedHelpers.filesystem_access(extension_dir, :create) do
146
148
  FileUtils.mkdir_p extension_dir
147
149
  end
148
- require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
149
150
  end
150
151
 
151
152
  def strict_rm_rf(dir)
@@ -20,10 +20,6 @@ module Bundler
20
20
  Gem::Requirement.new(req_str).satisfied_by?(version)
21
21
  end
22
22
 
23
- def supports_bundler_trampolining?
24
- provides?(">= 3.3.0.a")
25
- end
26
-
27
23
  def build_args
28
24
  require "rubygems/command"
29
25
  Gem::Command.build_args
@@ -34,6 +30,10 @@ module Bundler
34
30
  Gem::Command.build_args = args
35
31
  end
36
32
 
33
+ def set_target_rbconfig(path)
34
+ Gem.set_target_rbconfig(path)
35
+ end
36
+
37
37
  def loaded_specs(name)
38
38
  Gem.loaded_specs[name]
39
39
  end
@@ -134,6 +134,18 @@ module Bundler
134
134
  loaded_gem_paths.flatten
135
135
  end
136
136
 
137
+ def load_plugins
138
+ Gem.load_plugins
139
+ end
140
+
141
+ def load_plugin_files(plugin_files)
142
+ Gem.load_plugin_files(plugin_files)
143
+ end
144
+
145
+ def load_env_plugins
146
+ Gem.load_env_plugins
147
+ end
148
+
137
149
  def ui=(obj)
138
150
  Gem::DefaultUserInteraction.ui = obj
139
151
  end
@@ -220,9 +232,7 @@ module Bundler
220
232
  end
221
233
  end
222
234
 
223
- # Used to make bin stubs that are not created by bundler work
224
- # under bundler. The new Gem.bin_path only considers gems in
225
- # +specs+
235
+ # Used to give better error messages when activating specs outside of the current bundle
226
236
  def replace_bin_path(specs_by_name)
227
237
  gem_class = (class << Gem; self; end)
228
238
 
@@ -261,31 +271,6 @@ module Bundler
261
271
 
262
272
  spec
263
273
  end
264
-
265
- redefine_method(gem_class, :activate_bin_path) do |name, *args|
266
- exec_name = args.first
267
- return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
268
-
269
- # Copy of Rubygems activate_bin_path impl
270
- requirement = args.last
271
- spec = find_spec_for_exe name, exec_name, [requirement]
272
-
273
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
274
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
275
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
276
- end
277
-
278
- redefine_method(gem_class, :bin_path) do |name, *args|
279
- exec_name = args.first
280
- return ENV["BUNDLE_BIN_PATH"] if exec_name == "bundle"
281
-
282
- spec = find_spec_for_exe(name, *args)
283
- exec_name ||= spec.default_executable
284
-
285
- gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
286
- gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
287
- File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
288
- end
289
274
  end
290
275
 
291
276
  # Replace or hook into RubyGems to provide a bundlerized view
@@ -302,7 +287,7 @@ module Bundler
302
287
  Gem::BUNDLED_GEMS.replace_require(specs) if Gem::BUNDLED_GEMS.respond_to?(:replace_require)
303
288
  end
304
289
  replace_gem(specs, specs_by_name)
305
- stub_rubygems(specs)
290
+ stub_rubygems(specs_by_name.values)
306
291
  replace_bin_path(specs_by_name)
307
292
 
308
293
  Gem.clear_paths
@@ -331,11 +316,7 @@ module Bundler
331
316
  @replaced_methods.each do |(sym, klass), method|
332
317
  redefine_method(klass, sym, method)
333
318
  end
334
- if Binding.public_method_defined?(:source_location)
335
- post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
336
- else
337
- post_reset_hooks.reject! {|proc| proc.binding.eval("__FILE__") == __FILE__ }
338
- end
319
+ post_reset_hooks.reject! {|proc| proc.binding.source_location[0] == __FILE__ }
339
320
  @replaced_methods.clear
340
321
  end
341
322
 
@@ -412,7 +393,9 @@ module Bundler
412
393
  def download_gem(spec, uri, cache_dir, fetcher)
413
394
  require "rubygems/remote_fetcher"
414
395
  uri = Bundler.settings.mirror_for(uri)
415
- Bundler::Retry.new("download gem from #{uri}").attempts do
396
+ redacted_uri = Gem::Uri.redact(uri)
397
+
398
+ Bundler::Retry.new("download gem from #{redacted_uri}").attempts do
416
399
  gem_file_name = spec.file_name
417
400
  local_gem_path = File.join cache_dir, gem_file_name
418
401
  return if File.exist? local_gem_path
@@ -434,7 +417,7 @@ module Bundler
434
417
  end
435
418
  end
436
419
  rescue Gem::RemoteFetcher::FetchError => e
437
- raise Bundler::HTTPError, "Could not download gem from #{uri} due to underlying error <#{e.message}>"
420
+ raise Bundler::HTTPError, "Could not download gem from #{redacted_uri} due to underlying error <#{e.message}>"
438
421
  end
439
422
 
440
423
  def build(spec, skip_validation = false)
@@ -41,12 +41,17 @@ module Bundler
41
41
  groups.map!(&:to_sym)
42
42
  groups = [:default] if groups.empty?
43
43
 
44
- @definition.dependencies.each do |dep|
45
- # Skip the dependency if it is not in any of the requested groups, or
46
- # not for the current platform, or doesn't match the gem constraints.
47
- next unless (dep.groups & groups).any? && dep.should_include?
44
+ dependencies = @definition.dependencies.select do |dep|
45
+ # Select the dependency if it is in any of the requested groups, and
46
+ # for the current platform, and matches the gem constraints.
47
+ (dep.groups & groups).any? && dep.should_include?
48
+ end
49
+
50
+ Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE_ALL, dependencies)
48
51
 
52
+ dependencies.each do |dep|
49
53
  required_file = nil
54
+ Plugin.hook(Plugin::Events::GEM_BEFORE_REQUIRE, dep)
50
55
 
51
56
  begin
52
57
  # Loop through all the specified autorequires for the
@@ -76,7 +81,13 @@ module Bundler
76
81
  end
77
82
  end
78
83
  end
84
+
85
+ Plugin.hook(Plugin::Events::GEM_AFTER_REQUIRE, dep)
79
86
  end
87
+
88
+ Plugin.hook(Plugin::Events::GEM_AFTER_REQUIRE_ALL, dependencies)
89
+
90
+ dependencies
80
91
  end
81
92
 
82
93
  def self.definition_method(meth)
@@ -125,7 +136,16 @@ module Bundler
125
136
  specs_to_cache.each do |spec|
126
137
  next if spec.name == "bundler"
127
138
  next if spec.source.is_a?(Source::Gemspec)
128
- spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
139
+ if spec.source.respond_to?(:migrate_cache)
140
+ spec.source.migrate_cache(custom_path, local: local)
141
+ elsif spec.source.respond_to?(:cache)
142
+ spec.source.cache(spec, custom_path)
143
+ end
144
+ end
145
+
146
+ Dir[cache_path.join("*/.git")].each do |git_dir|
147
+ FileUtils.rm_rf(git_dir)
148
+ FileUtils.touch(File.expand_path("../.bundlecache", git_dir))
129
149
  end
130
150
 
131
151
  prune_cache(cache_path) unless Bundler.settings[:no_prune]
@@ -252,10 +272,10 @@ module Bundler
252
272
 
253
273
  def setup_manpath
254
274
  # Add man/ subdirectories from activated bundles to MANPATH for man(1)
255
- manuals = $LOAD_PATH.map do |path|
275
+ manuals = $LOAD_PATH.filter_map do |path|
256
276
  man_subdir = path.sub(/lib$/, "man")
257
277
  man_subdir unless Dir[man_subdir + "/man?/"].empty?
258
- end.compact
278
+ end
259
279
 
260
280
  return if manuals.empty?
261
281
  Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
@@ -84,8 +84,8 @@ module Bundler
84
84
  require "shellwords"
85
85
  cmd = [*Shellwords.shellsplit(bundler_spec_original_cmd), *ARGV]
86
86
  else
87
- cmd = [$PROGRAM_NAME, *ARGV]
88
- cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
87
+ cmd = [Process.argv0, *ARGV]
88
+ cmd.unshift(Gem.ruby) unless File.executable?(Process.argv0)
89
89
  end
90
90
 
91
91
  Bundler.with_original_env do
@@ -106,7 +106,6 @@ module Bundler
106
106
 
107
107
  def autoswitching_applies?
108
108
  ENV["BUNDLER_VERSION"].nil? &&
109
- Bundler.rubygems.supports_bundler_trampolining? &&
110
109
  ruby_can_restart_with_same_arguments? &&
111
110
  SharedHelpers.in_bundle? &&
112
111
  lockfile_version
@@ -32,6 +32,7 @@ module Bundler
32
32
  ignore_messages
33
33
  init_gems_rb
34
34
  inline
35
+ lockfile_checksums
35
36
  no_install
36
37
  no_prune
37
38
  path_relative_to_cwd
@@ -425,8 +426,12 @@ module Bundler
425
426
  Validator.validate!(raw_key, converted_value(value, raw_key), hash)
426
427
 
427
428
  return unless file
429
+
430
+ SharedHelpers.filesystem_access(file.dirname, :create) do |p|
431
+ FileUtils.mkdir_p(p)
432
+ end
433
+
428
434
  SharedHelpers.filesystem_access(file) do |p|
429
- FileUtils.mkdir_p(p.dirname)
430
435
  p.open("w") {|f| f.write(serializer_class.dump(hash)) }
431
436
  end
432
437
  end
@@ -96,14 +96,16 @@ module Bundler
96
96
  # given block
97
97
  #
98
98
  # @example
99
- # filesystem_access("vendor/cache", :write) do
99
+ # filesystem_access("vendor/cache", :create) do
100
100
  # FileUtils.mkdir_p("vendor/cache")
101
101
  # end
102
102
  #
103
103
  # @see {Bundler::PermissionError}
104
104
  def filesystem_access(path, action = :write, &block)
105
105
  yield(path.dup)
106
- rescue Errno::EACCES
106
+ rescue Errno::EACCES => e
107
+ raise unless e.message.include?(path.to_s) || action == :create
108
+
107
109
  raise PermissionError.new(path, action)
108
110
  rescue Errno::EAGAIN
109
111
  raise TemporaryResourceError.new(path, action)
@@ -116,7 +118,7 @@ module Bundler
116
118
  rescue Errno::EEXIST, Errno::ENOENT
117
119
  raise
118
120
  rescue SystemCallError => e
119
- raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
121
+ raise GenericSystemCallError.new(e, "There was an error #{[:create, :write].include?(action) ? "creating" : "accessing"} `#{path}`.")
120
122
  end
121
123
 
122
124
  def major_deprecation(major_version, message, removed_message: nil, print_caller_location: false)
@@ -160,10 +162,10 @@ module Bundler
160
162
  extra_deps = new_deps - old_deps
161
163
  return if extra_deps.empty?
162
164
 
163
- Bundler.ui.debug "#{spec.full_name} from #{spec.remote} has either corrupted API or lockfile dependencies" \
165
+ Bundler.ui.debug "#{spec.full_name} from #{spec.remote} has corrupted API dependencies" \
164
166
  " (was expecting #{old_deps.map(&:to_s)}, but the real spec has #{new_deps.map(&:to_s)})"
165
167
  raise APIResponseMismatchError,
166
- "Downloading #{spec.full_name} revealed dependencies not in the API or the lockfile (#{extra_deps.join(", ")})." \
168
+ "Downloading #{spec.full_name} revealed dependencies not in the API (#{extra_deps.join(", ")})." \
167
169
  "\nRunning `bundle update #{spec.name}` should fix the problem."
168
170
  end
169
171
 
@@ -274,15 +276,7 @@ module Bundler
274
276
  until !File.directory?(current) || current == previous
275
277
  if ENV["BUNDLER_SPEC_RUN"]
276
278
  # avoid stepping above the tmp directory when testing
277
- gemspec = if ENV["GEM_COMMAND"]
278
- # for Ruby Core
279
- "lib/bundler/bundler.gemspec"
280
- else
281
- "bundler.gemspec"
282
- end
283
-
284
- # avoid stepping above the tmp directory when testing
285
- return nil if File.file?(File.join(current, gemspec))
279
+ return nil if File.directory?(File.join(current, "tmp"))
286
280
  end
287
281
 
288
282
  names.each do |name|
@@ -314,18 +308,36 @@ module Bundler
314
308
 
315
309
  def bundle_bin_path
316
310
  # bundler exe & lib folders have same root folder, typical gem installation
317
- exe_file = File.expand_path("../../exe/bundle", __dir__)
311
+ exe_file = File.join(source_root, "exe/bundle")
318
312
 
319
313
  # for Ruby core repository testing
320
- exe_file = File.expand_path("../../libexec/bundle", __dir__) unless File.exist?(exe_file)
314
+ exe_file = File.join(source_root, "libexec/bundle") unless File.exist?(exe_file)
321
315
 
322
316
  # bundler is a default gem, exe path is separate
323
- exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
317
+ exe_file = Gem.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
324
318
 
325
319
  exe_file
326
320
  end
327
321
  public :bundle_bin_path
328
322
 
323
+ def gemspec_path
324
+ # inside a gem repository, typical gem installation
325
+ gemspec_file = File.join(source_root, "../../specifications/bundler-#{VERSION}.gemspec")
326
+
327
+ # for Ruby core repository testing
328
+ gemspec_file = File.expand_path("bundler.gemspec", __dir__) unless File.exist?(gemspec_file)
329
+
330
+ # bundler is a default gem
331
+ gemspec_file = File.join(Gem.default_specifications_dir, "bundler-#{VERSION}.gemspec") unless File.exist?(gemspec_file)
332
+
333
+ gemspec_file
334
+ end
335
+ public :gemspec_path
336
+
337
+ def source_root
338
+ File.expand_path("../..", __dir__)
339
+ end
340
+
329
341
  def set_path
330
342
  validate_bundle_path
331
343
  paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
@@ -84,12 +84,6 @@ module Bundler
84
84
  end
85
85
  end
86
86
 
87
- def not_a_repository?
88
- _, status = git_null("rev-parse", "--resolve-git-dir", path.to_s, dir: path)
89
-
90
- !status.success?
91
- end
92
-
93
87
  def contains?(commit)
94
88
  allowed_with_path do
95
89
  result, status = git_null("branch", "--contains", commit, dir: path)