bundler 2.5.5 → 2.5.16

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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +171 -0
  3. data/lib/bundler/build_metadata.rb +2 -2
  4. data/lib/bundler/cli/binstubs.rb +1 -1
  5. data/lib/bundler/cli/fund.rb +1 -1
  6. data/lib/bundler/cli/gem.rb +8 -15
  7. data/lib/bundler/cli/install.rb +1 -1
  8. data/lib/bundler/cli/lock.rb +5 -4
  9. data/lib/bundler/cli/plugin.rb +3 -2
  10. data/lib/bundler/cli.rb +14 -31
  11. data/lib/bundler/compact_index_client/cache.rb +47 -72
  12. data/lib/bundler/compact_index_client/parser.rb +84 -0
  13. data/lib/bundler/compact_index_client.rb +51 -80
  14. data/lib/bundler/constants.rb +8 -1
  15. data/lib/bundler/definition.rb +168 -99
  16. data/lib/bundler/dependency.rb +2 -1
  17. data/lib/bundler/dsl.rb +16 -1
  18. data/lib/bundler/endpoint_specification.rb +11 -0
  19. data/lib/bundler/env.rb +1 -1
  20. data/lib/bundler/environment_preserver.rb +5 -23
  21. data/lib/bundler/errors.rb +14 -0
  22. data/lib/bundler/fetcher/compact_index.rb +15 -24
  23. data/lib/bundler/fetcher/downloader.rb +1 -1
  24. data/lib/bundler/fetcher.rb +2 -2
  25. data/lib/bundler/gem_helper.rb +1 -1
  26. data/lib/bundler/gem_helpers.rb +14 -7
  27. data/lib/bundler/gem_version_promoter.rb +42 -38
  28. data/lib/bundler/injector.rb +4 -6
  29. data/lib/bundler/installer/gem_installer.rb +0 -1
  30. data/lib/bundler/installer/standalone.rb +0 -3
  31. data/lib/bundler/installer.rb +11 -13
  32. data/lib/bundler/lazy_specification.rb +1 -0
  33. data/lib/bundler/man/bundle-add.1 +1 -1
  34. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  35. data/lib/bundler/man/bundle-cache.1 +1 -1
  36. data/lib/bundler/man/bundle-check.1 +3 -1
  37. data/lib/bundler/man/bundle-check.1.ronn +3 -0
  38. data/lib/bundler/man/bundle-clean.1 +1 -1
  39. data/lib/bundler/man/bundle-config.1 +2 -4
  40. data/lib/bundler/man/bundle-config.1.ronn +1 -4
  41. data/lib/bundler/man/bundle-console.1 +1 -1
  42. data/lib/bundler/man/bundle-doctor.1 +1 -1
  43. data/lib/bundler/man/bundle-exec.1 +1 -1
  44. data/lib/bundler/man/bundle-gem.1 +7 -1
  45. data/lib/bundler/man/bundle-gem.1.ronn +11 -0
  46. data/lib/bundler/man/bundle-help.1 +1 -1
  47. data/lib/bundler/man/bundle-info.1 +1 -1
  48. data/lib/bundler/man/bundle-init.1 +1 -1
  49. data/lib/bundler/man/bundle-inject.1 +1 -1
  50. data/lib/bundler/man/bundle-install.1 +3 -3
  51. data/lib/bundler/man/bundle-install.1.ronn +2 -2
  52. data/lib/bundler/man/bundle-list.1 +1 -1
  53. data/lib/bundler/man/bundle-lock.1 +1 -1
  54. data/lib/bundler/man/bundle-open.1 +1 -1
  55. data/lib/bundler/man/bundle-outdated.1 +1 -1
  56. data/lib/bundler/man/bundle-platform.1 +1 -1
  57. data/lib/bundler/man/bundle-plugin.1 +7 -4
  58. data/lib/bundler/man/bundle-plugin.1.ronn +7 -3
  59. data/lib/bundler/man/bundle-pristine.1 +1 -1
  60. data/lib/bundler/man/bundle-remove.1 +1 -1
  61. data/lib/bundler/man/bundle-show.1 +1 -1
  62. data/lib/bundler/man/bundle-update.1 +1 -1
  63. data/lib/bundler/man/bundle-version.1 +1 -1
  64. data/lib/bundler/man/bundle-viz.1 +1 -1
  65. data/lib/bundler/man/bundle.1 +1 -1
  66. data/lib/bundler/man/gemfile.5 +3 -3
  67. data/lib/bundler/man/gemfile.5.ronn +2 -2
  68. data/lib/bundler/mirror.rb +3 -3
  69. data/lib/bundler/plugin/api/source.rb +2 -2
  70. data/lib/bundler/plugin/installer/path.rb +18 -0
  71. data/lib/bundler/plugin/installer.rb +36 -16
  72. data/lib/bundler/plugin/source_list.rb +4 -4
  73. data/lib/bundler/resolver/base.rb +4 -0
  74. data/lib/bundler/resolver/candidate.rb +5 -17
  75. data/lib/bundler/resolver/package.rb +4 -0
  76. data/lib/bundler/resolver/spec_group.rb +20 -2
  77. data/lib/bundler/resolver.rb +72 -33
  78. data/lib/bundler/rubygems_ext.rb +98 -10
  79. data/lib/bundler/rubygems_gem_installer.rb +35 -2
  80. data/lib/bundler/rubygems_integration.rb +16 -2
  81. data/lib/bundler/runtime.rb +2 -2
  82. data/lib/bundler/self_manager.rb +22 -2
  83. data/lib/bundler/settings.rb +26 -20
  84. data/lib/bundler/setup.rb +6 -0
  85. data/lib/bundler/shared_helpers.rb +6 -4
  86. data/lib/bundler/source/git/git_proxy.rb +9 -1
  87. data/lib/bundler/source/git.rb +15 -1
  88. data/lib/bundler/source/metadata.rb +2 -0
  89. data/lib/bundler/source/path.rb +0 -13
  90. data/lib/bundler/source/rubygems/remote.rb +1 -1
  91. data/lib/bundler/source/rubygems.rb +33 -32
  92. data/lib/bundler/source_list.rb +26 -2
  93. data/lib/bundler/spec_set.rb +15 -13
  94. data/lib/bundler/stub_specification.rb +8 -0
  95. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
  96. data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -3
  97. data/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
  98. data/lib/bundler/uri_credentials_filter.rb +2 -2
  99. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +22 -22
  100. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +1 -0
  101. data/lib/bundler/vendored_net_http.rb +20 -5
  102. data/lib/bundler/vendored_timeout.rb +7 -3
  103. data/lib/bundler/vendored_uri.rb +18 -1
  104. data/lib/bundler/version.rb +1 -1
  105. data/lib/bundler/yaml_serializer.rb +11 -6
  106. data/lib/bundler.rb +29 -3
  107. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaaf17b908dc3f0037d6da507f2177ef2cc21e023691c98f608d5ab3699431c2
4
- data.tar.gz: 64233d285e149e70f795b71cef8c92cff52360f9e86be7be3318067450c1da53
3
+ metadata.gz: 736fcd6d7bb9c8f0aaa8187d662846d4a17dc827b580d7912350e1e11f7b8c2a
4
+ data.tar.gz: 793b6ad42430c89e42202dc735637373f7e7e780e286c63ca603e05712cd4bc1
5
5
  SHA512:
6
- metadata.gz: 3033d4bad54a516fc1ef08d38f9de79aa79ea0a4f7c944e3c9f770808aa82f571b6caf8af6545281d3eca71022caeab475f478831a37fd78ed93b2627104a09b
7
- data.tar.gz: d0035deab10246f235ec44b910a7a4552b725a5f4372a9eee20119f1e073eac9d355cda044bb56ad50390a3f879ee161b29783847d9dad92d107b75013b7f88d
6
+ metadata.gz: 9246f1b4a399b0f70fc9309365922cd4759dab87cce71f1048c36c50ec5ebc2563c5942c72bf9815a1b9fe13656d3e59b9fd1b490b1f8e32db8f24769b5bdd02
7
+ data.tar.gz: d18554604463d8c50739086ee2c9587ca13d44fc24171ed8f4e4759be9a8f71902026a942cf7dcc6ecec74943f6b2c901d71c5455a152a21d5c304ccec87f70d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,174 @@
1
+ # 2.5.16 (July 18, 2024)
2
+
3
+ ## Bug fixes:
4
+
5
+ - Fix platform removal regression when `platforms:` used in the Gemfile [#7864](https://github.com/rubygems/rubygems/pull/7864)
6
+ - Fix standalone script when default gems with extensions are used [#7870](https://github.com/rubygems/rubygems/pull/7870)
7
+ - Fix another case of `bundle lock --add-platform` doing nothing [#7848](https://github.com/rubygems/rubygems/pull/7848)
8
+ - Fix bad error messages when using `bundle add` with frozen mode set [#7845](https://github.com/rubygems/rubygems/pull/7845)
9
+ - Fix generic platform gems getting incorrectly removed from lockfile [#7833](https://github.com/rubygems/rubygems/pull/7833)
10
+
11
+ ## Performance:
12
+
13
+ - Use `caller_locations` instead of splitting `caller` [#7708](https://github.com/rubygems/rubygems/pull/7708)
14
+
15
+ # 2.5.15 (July 9, 2024)
16
+
17
+ ## Enhancements:
18
+
19
+ - Support `--no-test`, `--no-ci`, and `--no-linter` options [#7780](https://github.com/rubygems/rubygems/pull/7780)
20
+ - Allow bundle command in new gems with invalid metadata [#7707](https://github.com/rubygems/rubygems/pull/7707)
21
+
22
+ ## Bug fixes:
23
+
24
+ - Protect creating RubyGems binstubs with a file lock [#7841](https://github.com/rubygems/rubygems/pull/7841)
25
+ - Only allow valid values for `--test`, `--ci`, and `--linter` options [#7801](https://github.com/rubygems/rubygems/pull/7801)
26
+ - Fix `bundle lock --add-platform <current_platform>` doing nothing [#7803](https://github.com/rubygems/rubygems/pull/7803)
27
+ - Print a proper error when bin dir does not have writable permission bit [#7794](https://github.com/rubygems/rubygems/pull/7794)
28
+
29
+ ## Documentation:
30
+
31
+ - Regenerate bundler docs for June 2024 [#7787](https://github.com/rubygems/rubygems/pull/7787)
32
+
33
+ # 2.5.14 (June 21, 2024)
34
+
35
+ ## Bug fixes:
36
+
37
+ - Fix credentials being re-added when re-resolving without a full unlock [#7767](https://github.com/rubygems/rubygems/pull/7767)
38
+ - Fix `bundle update <gem_name>` edge case [#7770](https://github.com/rubygems/rubygems/pull/7770)
39
+ - Fix `bundle fund` when the gemfile contains optional groups [#7758](https://github.com/rubygems/rubygems/pull/7758)
40
+
41
+ # 2.5.13 (June 14, 2024)
42
+
43
+ ## Bug fixes:
44
+
45
+ - Fix funding metadata not being printed in some situations [#7746](https://github.com/rubygems/rubygems/pull/7746)
46
+ - Make sure to not re-resolve when a not fully specific local platform is locked [#7751](https://github.com/rubygems/rubygems/pull/7751)
47
+ - Don't print bug report template when bin dir is not writable [#7748](https://github.com/rubygems/rubygems/pull/7748)
48
+
49
+ # 2.5.12 (June 13, 2024)
50
+
51
+ ## Enhancements:
52
+
53
+ - Keep credentials in lockfile if they are already there [#7720](https://github.com/rubygems/rubygems/pull/7720)
54
+ - Auto switch to locked bundler version even when using binstubs [#7719](https://github.com/rubygems/rubygems/pull/7719)
55
+ - Don't validate local gemspecs twice unnecessarily [#7725](https://github.com/rubygems/rubygems/pull/7725)
56
+ - Improve default gem handling by treating default gems as any other gem [#7673](https://github.com/rubygems/rubygems/pull/7673)
57
+
58
+ ## Bug fixes:
59
+
60
+ - Fix slow and incorrect resolution when adding `sorbet` to a Gemfile and the lockfile only includes "RUBY" in the platforms section [#7731](https://github.com/rubygems/rubygems/pull/7731)
61
+ - Fix duplicated config keys generated when `fallback_timeout` uri option is used [#7704](https://github.com/rubygems/rubygems/pull/7704)
62
+ - Fix `bundle exec` no longer working in truffleruby after explicit `require` of `pathname` was removed [#7703](https://github.com/rubygems/rubygems/pull/7703)
63
+ - Don't let `bundle config` report a path without a Gemfile as "local app" [#7687](https://github.com/rubygems/rubygems/pull/7687)
64
+
65
+ ## Documentation:
66
+
67
+ - Clarify BUNDLE_USER_CONFIG is a file [#7668](https://github.com/rubygems/rubygems/pull/7668)
68
+
69
+ # 2.5.11 (May 28, 2024)
70
+
71
+ ## Deprecations:
72
+
73
+ - Deprecate Bundler constants [#7653](https://github.com/rubygems/rubygems/pull/7653)
74
+
75
+ ## Enhancements:
76
+
77
+ - Bump `bundle gem` generated COC to Contributor Covenant 2.1 [#7692](https://github.com/rubygems/rubygems/pull/7692)
78
+ - Retry a full clone when git server does not support shallow capabilities [#7649](https://github.com/rubygems/rubygems/pull/7649)
79
+
80
+ ## Bug fixes:
81
+
82
+ - Fix regression when caching gems from secondary sources [#7659](https://github.com/rubygems/rubygems/pull/7659)
83
+ - Fix error when Bundler installation is corrupted [#7642](https://github.com/rubygems/rubygems/pull/7642)
84
+ - Fix crash caused by RubyGems `require` gem activation logic running before Bundler can properly register its own monkeypatches [#7647](https://github.com/rubygems/rubygems/pull/7647)
85
+
86
+ ## Performance:
87
+
88
+ - Update cache checksums to decrease string allocations [#7637](https://github.com/rubygems/rubygems/pull/7637)
89
+ - Fix performance regression in applications with a local cache [#7680](https://github.com/rubygems/rubygems/pull/7680)
90
+
91
+ ## Documentation:
92
+
93
+ - Recommend `bin/rake` over `rake` in contributing docs [#7648](https://github.com/rubygems/rubygems/pull/7648)
94
+ - Monthly man update for May 2024 [#7640](https://github.com/rubygems/rubygems/pull/7640)
95
+ - Clarify Bundler support policy [#7633](https://github.com/rubygems/rubygems/pull/7633)
96
+
97
+ # 2.5.10 (May 3, 2024)
98
+
99
+ ## Security:
100
+
101
+ - Never write credentials to lockfiles [#7560](https://github.com/rubygems/rubygems/pull/7560)
102
+
103
+ ## Enhancements:
104
+
105
+ - Add auto_install support to require "bundler/setup" [#6561](https://github.com/rubygems/rubygems/pull/6561)
106
+ - Add `--glob` flag to `bundle add` [#7557](https://github.com/rubygems/rubygems/pull/7557)
107
+
108
+ ## Bug fixes:
109
+
110
+ - Make sure `bundle update <specific_gems>` can always update to the latest resolvable version of each requested gem [#7558](https://github.com/rubygems/rubygems/pull/7558)
111
+ - Show better error when installed gemspecs are unreadable [#7603](https://github.com/rubygems/rubygems/pull/7603)
112
+ - Fix `bundle update` not working on an out of sync lockfile [#7607](https://github.com/rubygems/rubygems/pull/7607)
113
+ - Don't upcase Windows ENV before backing it up [#7574](https://github.com/rubygems/rubygems/pull/7574)
114
+ - Properly resolve aliases when `bundle help` is run [#7601](https://github.com/rubygems/rubygems/pull/7601)
115
+ - Fix issue installing gems with linux-musl variant on non musl linux [#7583](https://github.com/rubygems/rubygems/pull/7583)
116
+
117
+ ## Documentation:
118
+
119
+ - Clarify `bundle check` behaviour in docs [#7613](https://github.com/rubygems/rubygems/pull/7613)
120
+
121
+ # 2.5.9 (April 12, 2024)
122
+
123
+ ## Bug fixes:
124
+
125
+ - Fix installing plugins via relative paths [#7571](https://github.com/rubygems/rubygems/pull/7571)
126
+
127
+ # 2.5.8 (April 11, 2024)
128
+
129
+ ## Enhancements:
130
+
131
+ - Allow installing plugins from path via CLI [#6960](https://github.com/rubygems/rubygems/pull/6960)
132
+ - Improve validation of `bundle plugin install` options [#7529](https://github.com/rubygems/rubygems/pull/7529)
133
+
134
+ ## Bug fixes:
135
+
136
+ - Fix resolver error message when it runs out of versions due to `--strict --patch` filtering out everything [#7527](https://github.com/rubygems/rubygems/pull/7527)
137
+ - Fix incorrect `bundle update --bundler` message [#7516](https://github.com/rubygems/rubygems/pull/7516)
138
+
139
+ # 2.5.7 (March 22, 2024)
140
+
141
+ ## Deprecations:
142
+
143
+ - Deprecate `bundle plugin install --local-git=` [#7048](https://github.com/rubygems/rubygems/pull/7048)
144
+
145
+ ## Enhancements:
146
+
147
+ - Ignore commented out keys in config file [#7514](https://github.com/rubygems/rubygems/pull/7514)
148
+ - Fix exclusion of `.gemspec` file itself in `bundle gem` generated gemspec file [#7488](https://github.com/rubygems/rubygems/pull/7488)
149
+ - Remove redundant configs from `bundle gem` generated rubocop configuration [#7478](https://github.com/rubygems/rubygems/pull/7478)
150
+ - Add `gitlab:` git source shorthand [#7449](https://github.com/rubygems/rubygems/pull/7449)
151
+ - Use full path for `instance_eval` in `Bundler::DSL#eval_gemfile` [#7471](https://github.com/rubygems/rubygems/pull/7471)
152
+
153
+ ## Documentation:
154
+
155
+ - Use https instead of http in documentation links [#7481](https://github.com/rubygems/rubygems/pull/7481)
156
+
157
+ # 2.5.6 (February 6, 2024)
158
+
159
+ ## Deprecations:
160
+
161
+ - Refactor lockfile generation and deprecate `Definition#lock` with explicit lockfile [#7047](https://github.com/rubygems/rubygems/pull/7047)
162
+
163
+ ## Enhancements:
164
+
165
+ - Bump `required_ruby_version` to be used in `bundle gem` template [#7430](https://github.com/rubygems/rubygems/pull/7430)
166
+
167
+ ## Bug fixes:
168
+
169
+ - Fix musl platform not being added to the lockfile [#7441](https://github.com/rubygems/rubygems/pull/7441)
170
+ - Let `Bundler.with_original_env` properly restore env variables originally empty [#7383](https://github.com/rubygems/rubygems/pull/7383)
171
+
1
172
  # 2.5.5 (January 18, 2024)
2
173
 
3
174
  ## Bug fixes:
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2024-01-18".freeze
8
- @git_commit_sha = "2efa8cec93".freeze
7
+ @built_at = "2024-07-18".freeze
8
+ @git_commit_sha = "f49d3d48c9".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -45,7 +45,7 @@ module Bundler
45
45
  next
46
46
  end
47
47
 
48
- Bundler.settings.temporary(path: (Bundler.settings[:path] || Bundler.root)) do
48
+ Bundler.settings.temporary(path: Bundler.settings[:path] || Bundler.root) do
49
49
  installer.generate_standalone_bundler_executable_stubs(spec, installer_opts)
50
50
  end
51
51
  else
@@ -16,7 +16,7 @@ module Bundler
16
16
  deps = if groups.any?
17
17
  Bundler.definition.dependencies_for(groups)
18
18
  else
19
- Bundler.definition.current_dependencies
19
+ Bundler.definition.requested_dependencies
20
20
  end
21
21
 
22
22
  fund_info = deps.each_with_object([]) do |dep, arr|
@@ -32,7 +32,6 @@ module Bundler
32
32
 
33
33
  validate_ext_name if @extension
34
34
  validate_rust_builder_rubygems_version if @extension == "rust"
35
- travis_removal_info
36
35
  end
37
36
 
38
37
  def run
@@ -276,6 +275,7 @@ module Bundler
276
275
  end
277
276
 
278
277
  def ask_and_set_test_framework
278
+ return if skip?(:test)
279
279
  test_framework = options[:test] || Bundler.settings["gem.test"]
280
280
 
281
281
  if test_framework.to_s.empty?
@@ -301,6 +301,10 @@ module Bundler
301
301
  test_framework
302
302
  end
303
303
 
304
+ def skip?(option)
305
+ options.key?(option) && options[option].nil?
306
+ end
307
+
304
308
  def hint_text(setting)
305
309
  if Bundler.settings["gem.#{setting}"] == false
306
310
  "Your choice will only be applied to this gem."
@@ -311,6 +315,7 @@ module Bundler
311
315
  end
312
316
 
313
317
  def ask_and_set_ci
318
+ return if skip?(:ci)
314
319
  ci_template = options[:ci] || Bundler.settings["gem.ci"]
315
320
 
316
321
  if ci_template.to_s.empty?
@@ -342,6 +347,7 @@ module Bundler
342
347
  end
343
348
 
344
349
  def ask_and_set_linter
350
+ return if skip?(:linter)
345
351
  linter_template = options[:linter] || Bundler.settings["gem.linter"]
346
352
  linter_template = deprecated_rubocop_option if linter_template.nil?
347
353
 
@@ -437,7 +443,7 @@ module Bundler
437
443
  end
438
444
 
439
445
  def required_ruby_version
440
- "2.6.0"
446
+ "3.0.0"
441
447
  end
442
448
 
443
449
  def rubocop_version
@@ -448,19 +454,6 @@ module Bundler
448
454
  "1.3"
449
455
  end
450
456
 
451
- # TODO: remove at next minor release
452
- def travis_removal_info
453
- if options[:ci] == "travis"
454
- Bundler.ui.error "Support for Travis CI was removed from gem skeleton generator."
455
- exit 1
456
- end
457
-
458
- if Bundler.settings["gem.ci"] == "travis"
459
- Bundler.ui.error "Support for Travis CI was removed from gem skeleton generator, but it is present in bundle config. Please configure another provider using `bundle config set gem.ci SERVICE` (where SERVICE is one of github/gitlab/circle) or unset configuration using `bundle config unset gem.ci`."
460
- exit 1
461
- end
462
- end
463
-
464
457
  def validate_rust_builder_rubygems_version
465
458
  if Gem::Version.new(rust_builder_required_rubygems_version) > Gem.rubygems_version
466
459
  Bundler.ui.error "Your RubyGems version (#{Gem.rubygems_version}) is too old to build Rust extension. Please update your RubyGems using `gem update --system` or any other way and try again."
@@ -14,7 +14,7 @@ module Bundler
14
14
 
15
15
  Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
16
16
 
17
- Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
17
+ Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?
18
18
 
19
19
  # Disable color in deployment mode
20
20
  Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
@@ -33,8 +33,11 @@ module Bundler
33
33
  update = { bundler: bundler }
34
34
  end
35
35
 
36
+ file = options[:lockfile]
37
+ file = file ? Pathname.new(file).expand_path : Bundler.default_lockfile
38
+
36
39
  Bundler.settings.temporary(frozen: false) do
37
- definition = Bundler.definition(update)
40
+ definition = Bundler.definition(update, file)
38
41
 
39
42
  Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
40
43
 
@@ -60,10 +63,8 @@ module Bundler
60
63
  if print
61
64
  puts definition.to_lock
62
65
  else
63
- file = options[:lockfile]
64
- file = file ? File.expand_path(file) : Bundler.default_lockfile
65
66
  puts "Writing lockfile to #{file}"
66
- definition.lock(file)
67
+ definition.lock
67
68
  end
68
69
  end
69
70
 
@@ -5,14 +5,15 @@ module Bundler
5
5
  class CLI::Plugin < Thor
6
6
  desc "install PLUGINS", "Install the plugin from the source"
7
7
  long_desc <<-D
8
- Install plugins either from the rubygems source provided (with --source option) or from a git source provided with --git (for remote repos) or --local_git (for local repos). If no sources are provided, it uses Gem.sources
8
+ Install plugins either from the rubygems source provided (with --source option), from a git source provided with --git, or a local path provided with --path. If no sources are provided, it uses Gem.sources
9
9
  D
10
10
  method_option "source", type: :string, default: nil, banner: "URL of the RubyGems source to fetch the plugin from"
11
11
  method_option "version", type: :string, default: nil, banner: "The version of the plugin to fetch"
12
12
  method_option "git", type: :string, default: nil, banner: "URL of the git repo to fetch from"
13
- method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from"
13
+ method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from (deprecated)"
14
14
  method_option "branch", type: :string, default: nil, banner: "The git branch to checkout"
15
15
  method_option "ref", type: :string, default: nil, banner: "The git revision to check out"
16
+ method_option "path", type: :string, default: nil, banner: "Path of a local gem to directly use"
16
17
  def install(*plugins)
17
18
  Bundler::Plugin.install(plugins, options)
18
19
  end
data/lib/bundler/cli.rb CHANGED
@@ -5,6 +5,7 @@ require_relative "vendored_thor"
5
5
  module Bundler
6
6
  class CLI < Thor
7
7
  require_relative "cli/common"
8
+ require_relative "cli/install"
8
9
 
9
10
  package_name "Bundler"
10
11
 
@@ -64,12 +65,12 @@ module Bundler
64
65
  Bundler.reset_settings_and_root!
65
66
  end
66
67
 
67
- Bundler.self_manager.restart_with_locked_bundler_if_needed
68
+ Bundler.auto_switch
68
69
 
69
70
  Bundler.settings.set_command_option_if_given :retry, options[:retry]
70
71
 
71
72
  current_cmd = args.last[:current_command].name
72
- auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
73
+ Bundler.auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
73
74
  rescue UnknownArgumentError => e
74
75
  raise InvalidOption, e.message
75
76
  ensure
@@ -114,6 +115,8 @@ module Bundler
114
115
  class_option "verbose", type: :boolean, desc: "Enable verbose output mode", aliases: "-V"
115
116
 
116
117
  def help(cli = nil)
118
+ cli = self.class.all_aliases[cli] if self.class.all_aliases[cli]
119
+
117
120
  case cli
118
121
  when "gemfile" then command = "gemfile"
119
122
  when nil then command = "bundle"
@@ -347,6 +350,7 @@ module Bundler
347
350
  method_option "github", type: :string
348
351
  method_option "branch", type: :string
349
352
  method_option "ref", type: :string
353
+ method_option "glob", type: :string, banner: "The location of a dependency's .gemspec, expanded within Ruby (single quotes recommended)"
350
354
  method_option "skip-install", type: :boolean, banner: "Adds gem to the Gemfile but does not install it"
351
355
  method_option "optimistic", type: :boolean, banner: "Adds optimistic declaration of version to gem"
352
356
  method_option "strict", type: :boolean, banner: "Adds strict declaration of version to gem"
@@ -546,10 +550,13 @@ module Bundler
546
550
  method_option :rubocop, type: :boolean, desc: "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
547
551
  method_option :changelog, type: :boolean, desc: "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
548
552
  method_option :test, type: :string, lazy_default: Bundler.settings["gem.test"] || "", aliases: "-t", banner: "Use the specified test framework for your library",
553
+ enum: %w[rspec minitest test-unit],
549
554
  desc: "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
550
555
  method_option :ci, type: :string, lazy_default: Bundler.settings["gem.ci"] || "",
556
+ enum: %w[github gitlab circle],
551
557
  desc: "Generate CI configuration, either GitHub Actions, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|gitlab|circle)`"
552
558
  method_option :linter, type: :string, lazy_default: Bundler.settings["gem.linter"] || "",
559
+ enum: %w[rubocop standard],
553
560
  desc: "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
554
561
  method_option :github_username, type: :string, default: Bundler.settings["gem.github_username"], banner: "Set your username on GitHub", desc: "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
555
562
 
@@ -620,7 +627,7 @@ module Bundler
620
627
  method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
621
628
  method_option "pre", type: :boolean, banner: "If updating, always choose the highest allowed version, regardless of prerelease status"
622
629
  method_option "strict", type: :boolean, banner: "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
623
- method_option "conservative", type: :boolean, banner: "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
630
+ method_option "conservative", type: :boolean, banner: "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
624
631
  method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
625
632
  def lock
626
633
  require_relative "cli/lock"
@@ -682,7 +689,6 @@ module Bundler
682
689
  exec_used = args.index {|a| exec_commands.include? a }
683
690
 
684
691
  command = args.find {|a| bundler_commands.include? a }
685
- command = all_aliases[command] if all_aliases[command]
686
692
 
687
693
  if exec_used && help_used
688
694
  if exec_used + help_used == 1
@@ -735,26 +741,6 @@ module Bundler
735
741
 
736
742
  private
737
743
 
738
- # Automatically invoke `bundle install` and resume if
739
- # Bundler.settings[:auto_install] exists. This is set through config cmd
740
- # `bundle config set --global auto_install 1`.
741
- #
742
- # Note that this method `nil`s out the global Definition object, so it
743
- # should be called first, before you instantiate anything like an
744
- # `Installer` that'll keep a reference to the old one instead.
745
- def auto_install
746
- return unless Bundler.settings[:auto_install]
747
-
748
- begin
749
- Bundler.definition.specs
750
- rescue GemNotFound, GitError
751
- Bundler.ui.info "Automatically installing missing gems."
752
- Bundler.reset!
753
- invoke :install, []
754
- Bundler.reset!
755
- end
756
- end
757
-
758
744
  def current_command
759
745
  _, _, config = @_initializer
760
746
  config[:current_command]
@@ -784,13 +770,10 @@ module Bundler
784
770
 
785
771
  return unless SharedHelpers.md5_available?
786
772
 
787
- latest = Fetcher::CompactIndex.
788
- new(nil, Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org")), nil, nil).
789
- send(:compact_index_client).
790
- instance_variable_get(:@cache).
791
- dependencies("bundler").
792
- map {|d| Gem::Version.new(d.first) }.
793
- max
773
+ require_relative "vendored_uri"
774
+ remote = Source::Rubygems::Remote.new(Gem::URI("https://rubygems.org"))
775
+ cache_path = Bundler.user_cache.join("compact_index", remote.cache_slug)
776
+ latest = Bundler::CompactIndexClient.new(cache_path).latest_version("bundler")
794
777
  return unless latest
795
778
 
796
779
  current = Gem::Version.new(VERSION)
@@ -7,114 +7,89 @@ module Bundler
7
7
  class Cache
8
8
  attr_reader :directory
9
9
 
10
- def initialize(directory)
10
+ def initialize(directory, fetcher = nil)
11
11
  @directory = Pathname.new(directory).expand_path
12
- info_roots.each {|dir| mkdir(dir) }
13
- mkdir(info_etag_root)
12
+ @updater = Updater.new(fetcher) if fetcher
13
+ @mutex = Thread::Mutex.new
14
+ @endpoints = Set.new
15
+
16
+ @info_root = mkdir("info")
17
+ @special_characters_info_root = mkdir("info-special-characters")
18
+ @info_etag_root = mkdir("info-etags")
14
19
  end
15
20
 
16
21
  def names
17
- lines(names_path)
22
+ fetch("names", names_path, names_etag_path)
18
23
  end
19
24
 
20
- def names_path
21
- directory.join("names")
25
+ def versions
26
+ fetch("versions", versions_path, versions_etag_path)
22
27
  end
23
28
 
24
- def names_etag_path
25
- directory.join("names.etag")
26
- end
29
+ def info(name, remote_checksum = nil)
30
+ path = info_path(name)
27
31
 
28
- def versions
29
- versions_by_name = Hash.new {|hash, key| hash[key] = [] }
30
- info_checksums_by_name = {}
31
-
32
- lines(versions_path).each do |line|
33
- name, versions_string, info_checksum = line.split(" ", 3)
34
- info_checksums_by_name[name] = info_checksum || ""
35
- versions_string.split(",") do |version|
36
- delete = version.delete_prefix!("-")
37
- version = version.split("-", 2).unshift(name)
38
- if delete
39
- versions_by_name[name].delete(version)
40
- else
41
- versions_by_name[name] << version
42
- end
43
- end
32
+ if remote_checksum && remote_checksum != SharedHelpers.checksum_for_file(path, :MD5)
33
+ fetch("info/#{name}", path, info_etag_path(name))
34
+ else
35
+ Bundler::CompactIndexClient.debug { "update skipped info/#{name} (#{remote_checksum ? "versions index checksum is nil" : "versions index checksum matches local"})" }
36
+ read(path)
44
37
  end
45
-
46
- [versions_by_name, info_checksums_by_name]
47
- end
48
-
49
- def versions_path
50
- directory.join("versions")
51
38
  end
52
39
 
53
- def versions_etag_path
54
- directory.join("versions.etag")
40
+ def reset!
41
+ @mutex.synchronize { @endpoints.clear }
55
42
  end
56
43
 
57
- def checksums
58
- checksums = {}
59
-
60
- lines(versions_path).each do |line|
61
- name, _, checksum = line.split(" ", 3)
62
- checksums[name] = checksum
63
- end
64
-
65
- checksums
66
- end
44
+ private
67
45
 
68
- def dependencies(name)
69
- lines(info_path(name)).map do |line|
70
- parse_gem(line)
71
- end
72
- end
46
+ def names_path = directory.join("names")
47
+ def names_etag_path = directory.join("names.etag")
48
+ def versions_path = directory.join("versions")
49
+ def versions_etag_path = directory.join("versions.etag")
73
50
 
74
51
  def info_path(name)
75
52
  name = name.to_s
53
+ # TODO: converge this into the info_root by hashing all filenames like info_etag_path
76
54
  if /[^a-z0-9_-]/.match?(name)
77
55
  name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
78
- info_roots.last.join(name)
56
+ @special_characters_info_root.join(name)
79
57
  else
80
- info_roots.first.join(name)
58
+ @info_root.join(name)
81
59
  end
82
60
  end
83
61
 
84
62
  def info_etag_path(name)
85
63
  name = name.to_s
86
- info_etag_root.join("#{name}-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}")
64
+ @info_etag_root.join("#{name}-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}")
87
65
  end
88
66
 
89
- private
90
-
91
- def mkdir(dir)
92
- SharedHelpers.filesystem_access(dir) do
93
- FileUtils.mkdir_p(dir)
67
+ def mkdir(name)
68
+ directory.join(name).tap do |dir|
69
+ SharedHelpers.filesystem_access(dir) do
70
+ FileUtils.mkdir_p(dir)
71
+ end
94
72
  end
95
73
  end
96
74
 
97
- def lines(path)
98
- return [] unless path.file?
99
- lines = SharedHelpers.filesystem_access(path, :read, &:read).split("\n")
100
- header = lines.index("---")
101
- header ? lines[header + 1..-1] : lines
102
- end
75
+ def fetch(remote_path, path, etag_path)
76
+ if already_fetched?(remote_path)
77
+ Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
78
+ else
79
+ Bundler::CompactIndexClient.debug { "fetching #{remote_path}" }
80
+ @updater&.update(remote_path, path, etag_path)
81
+ end
103
82
 
104
- def parse_gem(line)
105
- @dependency_parser ||= GemParser.new
106
- @dependency_parser.parse(line)
83
+ read(path)
107
84
  end
108
85
 
109
- def info_roots
110
- [
111
- directory.join("info"),
112
- directory.join("info-special-characters"),
113
- ]
86
+ def already_fetched?(remote_path)
87
+ @mutex.synchronize { !@endpoints.add?(remote_path) }
114
88
  end
115
89
 
116
- def info_etag_root
117
- directory.join("info-etags")
90
+ def read(path)
91
+ return unless path.file?
92
+ SharedHelpers.filesystem_access(path, :read, &:read)
118
93
  end
119
94
  end
120
95
  end