bundler 2.6.3 → 2.6.9

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 (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +119 -6
  3. data/README.md +1 -1
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/checksum.rb +22 -12
  6. data/lib/bundler/cli/console.rb +8 -6
  7. data/lib/bundler/cli/doctor/diagnose.rb +167 -0
  8. data/lib/bundler/cli/doctor/ssl.rb +249 -0
  9. data/lib/bundler/cli/doctor.rb +27 -151
  10. data/lib/bundler/cli/info.rb +4 -4
  11. data/lib/bundler/cli/inject.rb +2 -2
  12. data/lib/bundler/cli/issue.rb +3 -3
  13. data/lib/bundler/cli/lock.rb +2 -1
  14. data/lib/bundler/cli/show.rb +1 -1
  15. data/lib/bundler/cli.rb +2 -11
  16. data/lib/bundler/compact_index_client/cache.rb +1 -1
  17. data/lib/bundler/compact_index_client/parser.rb +1 -1
  18. data/lib/bundler/compact_index_client/updater.rb +2 -1
  19. data/lib/bundler/current_ruby.rb +23 -33
  20. data/lib/bundler/definition.rb +220 -184
  21. data/lib/bundler/dependency.rb +92 -47
  22. data/lib/bundler/dsl.rb +84 -80
  23. data/lib/bundler/endpoint_specification.rb +10 -3
  24. data/lib/bundler/errors.rb +22 -0
  25. data/lib/bundler/friendly_errors.rb +1 -1
  26. data/lib/bundler/gem_helpers.rb +4 -10
  27. data/lib/bundler/gem_version_promoter.rb +0 -2
  28. data/lib/bundler/injector.rb +9 -9
  29. data/lib/bundler/installer.rb +2 -2
  30. data/lib/bundler/lazy_specification.rb +67 -45
  31. data/lib/bundler/lockfile_parser.rb +8 -5
  32. data/lib/bundler/man/bundle-add.1 +1 -1
  33. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  34. data/lib/bundler/man/bundle-cache.1 +1 -1
  35. data/lib/bundler/man/bundle-check.1 +1 -1
  36. data/lib/bundler/man/bundle-clean.1 +1 -1
  37. data/lib/bundler/man/bundle-config.1 +6 -6
  38. data/lib/bundler/man/bundle-config.1.ronn +9 -4
  39. data/lib/bundler/man/bundle-console.1 +1 -1
  40. data/lib/bundler/man/bundle-doctor.1 +1 -1
  41. data/lib/bundler/man/bundle-env.1 +1 -1
  42. data/lib/bundler/man/bundle-exec.1 +3 -3
  43. data/lib/bundler/man/bundle-exec.1.ronn +2 -2
  44. data/lib/bundler/man/bundle-fund.1 +1 -1
  45. data/lib/bundler/man/bundle-gem.1 +1 -1
  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 +1 -1
  51. data/lib/bundler/man/bundle-issue.1 +1 -1
  52. data/lib/bundler/man/bundle-licenses.1 +1 -1
  53. data/lib/bundler/man/bundle-list.1 +1 -1
  54. data/lib/bundler/man/bundle-lock.1 +1 -1
  55. data/lib/bundler/man/bundle-open.1 +1 -1
  56. data/lib/bundler/man/bundle-outdated.1 +1 -1
  57. data/lib/bundler/man/bundle-platform.1 +1 -1
  58. data/lib/bundler/man/bundle-plugin.1 +1 -1
  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 +1 -1
  67. data/lib/bundler/match_metadata.rb +13 -0
  68. data/lib/bundler/plugin/api/source.rb +1 -1
  69. data/lib/bundler/plugin/index.rb +1 -1
  70. data/lib/bundler/plugin/installer/path.rb +8 -0
  71. data/lib/bundler/plugin.rb +1 -1
  72. data/lib/bundler/resolver/candidate.rb +12 -9
  73. data/lib/bundler/resolver/package.rb +7 -3
  74. data/lib/bundler/resolver/spec_group.rb +1 -25
  75. data/lib/bundler/resolver/strategy.rb +40 -0
  76. data/lib/bundler/resolver.rb +29 -27
  77. data/lib/bundler/rubygems_ext.rb +97 -81
  78. data/lib/bundler/rubygems_integration.rb +2 -3
  79. data/lib/bundler/runtime.rb +27 -29
  80. data/lib/bundler/shared_helpers.rb +4 -0
  81. data/lib/bundler/source/gemspec.rb +1 -4
  82. data/lib/bundler/source/git/git_proxy.rb +14 -3
  83. data/lib/bundler/source/git.rb +5 -1
  84. data/lib/bundler/source/path.rb +2 -2
  85. data/lib/bundler/source/rubygems/remote.rb +11 -3
  86. data/lib/bundler/source/rubygems.rb +19 -4
  87. data/lib/bundler/source.rb +2 -0
  88. data/lib/bundler/source_list.rb +33 -11
  89. data/lib/bundler/spec_set.rb +98 -40
  90. data/lib/bundler/templates/newgem/Gemfile.tt +1 -0
  91. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +53 -3
  92. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  93. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +11 -0
  94. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +4 -24
  95. data/lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb +42 -0
  96. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +20 -8
  97. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +17 -29
  98. data/lib/bundler/vendor/uri/lib/uri/common.rb +7 -3
  99. data/lib/bundler/vendor/uri/lib/uri/generic.rb +12 -11
  100. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +6 -6
  101. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  102. data/lib/bundler/version.rb +1 -1
  103. metadata +7 -4
  104. data/lib/bundler/compact_index_client/gem_parser.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3feddb9042d8a7e98b180bdccc1fc1589782cbd67d813abb63aac8a84028a811
4
- data.tar.gz: 2f8ed118d6ca1e4e4301e977e23bd94897bbb5fc79c8b4a5799fe47f3ee306f1
3
+ metadata.gz: 855ce06e8526e58b49de6b5872997ade47beb38288f5cf783ad551417accfa2c
4
+ data.tar.gz: bfa8b4371917aa0b993a31d9452196c00239de57803b0a233795040be5e158f0
5
5
  SHA512:
6
- metadata.gz: 628abd13ffccef88bb5eebf10c73bc40157b8cd0e5d1b07930be534b5b161732710c5794fd5efa830a7d493f2af0bf58bf1aa3601ea9ba0c56aee8f2ca0cdd77
7
- data.tar.gz: fbca6f3eba226a373edce1d0987a31d07fbb0ea0ce8d8ebd05cda8a6184c22158a25090317173f4b1e839d6b45c31bfe9dee9f7cb8c26bbfb05670947fe8bf09
6
+ metadata.gz: bdf0dab626499ae76ef5fae750d9354c8c064fc19cb4b357de8e11bb1036246d8b0aed7fe12d2dbec3a81745db31b6268c4c4fec14111c5b224c96217834f8d9
7
+ data.tar.gz: c297223566644f831412d15723e0cd96a1f9d7c9d6d2985596716dd1a00d7b3f386014402403fbefb0fa0805e36662de35268bd3b2ab7168ce08f1ee34a31f29
data/CHANGELOG.md CHANGED
@@ -1,3 +1,116 @@
1
+ # 2.6.9 (May 13, 2025)
2
+
3
+ ## Enhancements:
4
+
5
+ - Fix doctor command parsing of otool output [#8665](https://github.com/rubygems/rubygems/pull/8665)
6
+ - Add SSL troubleshooting to `bundle doctor` [#8624](https://github.com/rubygems/rubygems/pull/8624)
7
+ - Let `bundle lock --normalize-platforms` remove invalid platforms [#8631](https://github.com/rubygems/rubygems/pull/8631)
8
+
9
+ ## Bug fixes:
10
+
11
+ - Fix `bundle lock` sometimes allowing invalid platforms into the lockfile [#8630](https://github.com/rubygems/rubygems/pull/8630)
12
+ - Fix false positive warning about insecure materialization in frozen mode [#8629](https://github.com/rubygems/rubygems/pull/8629)
13
+
14
+ # 2.6.8 (April 13, 2025)
15
+
16
+ ## Enhancements:
17
+
18
+ - Refine `bundle update --verbose` logs [#8627](https://github.com/rubygems/rubygems/pull/8627)
19
+ - Improve bug report instructions [#8607](https://github.com/rubygems/rubygems/pull/8607)
20
+
21
+ ## Bug fixes:
22
+
23
+ - Fix `bundle update` crash in an edge case [#8626](https://github.com/rubygems/rubygems/pull/8626)
24
+ - Fix `bundle lock --normalize-platforms` regression [#8620](https://github.com/rubygems/rubygems/pull/8620)
25
+
26
+ # 2.6.7 (April 3, 2025)
27
+
28
+ ## Enhancements:
29
+
30
+ - Fix crash when server compact index API implementation only lists versions [#8594](https://github.com/rubygems/rubygems/pull/8594)
31
+ - Fix lockfile when a gem ends up accidentally under two different sources [#8579](https://github.com/rubygems/rubygems/pull/8579)
32
+ - Refuse to install and print an error in frozen mode if some entries are missing in CHECKSUMS lockfile section [#8563](https://github.com/rubygems/rubygems/pull/8563)
33
+ - Support git 2.49 [#8581](https://github.com/rubygems/rubygems/pull/8581)
34
+ - Improve wording of a few messages [#8570](https://github.com/rubygems/rubygems/pull/8570)
35
+
36
+ ## Bug fixes:
37
+
38
+ - Fix `bundle add` sometimes generating invalid lockfiles [#8586](https://github.com/rubygems/rubygems/pull/8586)
39
+
40
+ ## Performance:
41
+
42
+ - Implement pub_grub strategy interface [#8589](https://github.com/rubygems/rubygems/pull/8589)
43
+ - Update vendored pub_grub [#8571](https://github.com/rubygems/rubygems/pull/8571)
44
+
45
+ # 2.6.6 (March 13, 2025)
46
+
47
+ ## Enhancements:
48
+
49
+ - Fix `ENAMETOOLONG` error when creating compact index cache [#5578](https://github.com/rubygems/rubygems/pull/5578)
50
+ - Use shorthand hash syntax for bundle add [#8547](https://github.com/rubygems/rubygems/pull/8547)
51
+ - Update vendored uri to 1.0.3 [#8534](https://github.com/rubygems/rubygems/pull/8534)
52
+ - Retry gracefully on blank partial response in compact index [#8524](https://github.com/rubygems/rubygems/pull/8524)
53
+ - Give a better error when trying to write the lock file on a read-only filesystem [#5920](https://github.com/rubygems/rubygems/pull/5920)
54
+ - Improve log messages when lockfile platforms are added [#8523](https://github.com/rubygems/rubygems/pull/8523)
55
+ - Allow noop `bundle install` to work on read-only or protected folders [#8519](https://github.com/rubygems/rubygems/pull/8519)
56
+
57
+ ## Bug fixes:
58
+
59
+ - Detect partial gem installs from a git source so that they are reinstalled on a successive run [#8539](https://github.com/rubygems/rubygems/pull/8539)
60
+ - Modify `bundle doctor` to not report issue when files aren't writable [#8520](https://github.com/rubygems/rubygems/pull/8520)
61
+
62
+ ## Performance:
63
+
64
+ - Optimize resolution by removing an array allocation from `Candidate#<=>` [#8559](https://github.com/rubygems/rubygems/pull/8559)
65
+
66
+ ## Documentation:
67
+
68
+ - Update docs for with/without consistency [#8555](https://github.com/rubygems/rubygems/pull/8555)
69
+ - Recommend non-deprecated methods in `bundle exec` documentation [#8537](https://github.com/rubygems/rubygems/pull/8537)
70
+ - Hint about default group when using `only` configuration option [#8536](https://github.com/rubygems/rubygems/pull/8536)
71
+
72
+ # 2.6.5 (February 20, 2025)
73
+
74
+ ## Enhancements:
75
+
76
+ - Fix lockfile platforms inconveniently added on JRuby [#8494](https://github.com/rubygems/rubygems/pull/8494)
77
+
78
+ ## Bug fixes:
79
+
80
+ - Fix resolver issue due to ill-defined version ranges being created [#8503](https://github.com/rubygems/rubygems/pull/8503)
81
+ - Make sure empty gems are not reinstalled every time [#8502](https://github.com/rubygems/rubygems/pull/8502)
82
+
83
+ # 2.6.4 (February 17, 2025)
84
+
85
+ ## Enhancements:
86
+
87
+ - Make Bundler never instantiate development dependencies [#8486](https://github.com/rubygems/rubygems/pull/8486)
88
+ - Fix some invalid options to `gem` DSL not getting reported as invalid [#8480](https://github.com/rubygems/rubygems/pull/8480)
89
+ - Add `irb` to a Gemfile for a newly created gem [#8467](https://github.com/rubygems/rubygems/pull/8467)
90
+ - Auto-heal empty installation directory [#8457](https://github.com/rubygems/rubygems/pull/8457)
91
+ - Fix `bundle console` unnecessarily trying to load IRB twice [#8443](https://github.com/rubygems/rubygems/pull/8443)
92
+ - Add ruby_34 and ruby_35 as valid platform: [#8430](https://github.com/rubygems/rubygems/pull/8430)
93
+ - Consider gems under `platform: :windows` filter in Gemfile when running on Windows with ARM architecture [#8428](https://github.com/rubygems/rubygems/pull/8428)
94
+
95
+ ## Bug fixes:
96
+
97
+ - Fix regression when running `bundle update <foo>` would sometimes downgrade a top level dependency [#8491](https://github.com/rubygems/rubygems/pull/8491)
98
+ - Fix dependency locking when Bundler finds incorrect lockfile dependencies [#8489](https://github.com/rubygems/rubygems/pull/8489)
99
+ - Raise error when lockfile is missing deps in frozen mode [#8483](https://github.com/rubygems/rubygems/pull/8483)
100
+ - Fix `bundle install --prefer-local` sometimes installing very old versions [#8484](https://github.com/rubygems/rubygems/pull/8484)
101
+ - Fix incorrect error message when running `bundle update` in frozen mode [#8481](https://github.com/rubygems/rubygems/pull/8481)
102
+ - Keep platform variants in `vendor/cache` even if incompatible with the current Ruby version [#8471](https://github.com/rubygems/rubygems/pull/8471)
103
+ - Fix `bundle console` printing bug report template incorrectly [#8436](https://github.com/rubygems/rubygems/pull/8436)
104
+ - Fix `--prefer-local` not respecting default gems [#8412](https://github.com/rubygems/rubygems/pull/8412)
105
+
106
+ ## Performance:
107
+
108
+ - Improve resolution performance [#8458](https://github.com/rubygems/rubygems/pull/8458)
109
+
110
+ ## Documentation:
111
+
112
+ - Fix more broken links [#8416](https://github.com/rubygems/rubygems/pull/8416)
113
+
1
114
  # 2.6.3 (January 16, 2025)
2
115
 
3
116
  ## Enhancements:
@@ -1249,7 +1362,7 @@
1249
1362
  - Enable parallel installation on Windows by default [#4822](https://github.com/rubygems/rubygems/pull/4822)
1250
1363
  - More logging when compact index is not used and we fallback to other APIs [#4546](https://github.com/rubygems/rubygems/pull/4546)
1251
1364
  - `bundle gem` generated MiniTest file and class now start with 'test' [#3893](https://github.com/rubygems/rubygems/pull/3893)
1252
- - Add `Bundler::Definition.no_lock` accessor for skipping lock file creation/update [#3401](https://github.com/rubygems/rubygems/pull/3401)
1365
+ - Add `Bundler::Definition.no_lock` accessor for skipping lockfile creation/update [#3401](https://github.com/rubygems/rubygems/pull/3401)
1253
1366
 
1254
1367
  ## Bug fixes:
1255
1368
 
@@ -1991,7 +2104,7 @@
1991
2104
  - Fix `bundle outdated --group NAME` when the group is listed second in the Gemfile ([#6116](https://github.com/rubygems/bundler/pull/6116))
1992
2105
  - Improve conflict resolution messages by not calling "ruby" a gem when conflict happens in the `required_ruby_version`, and by filtering out requirements that didn't contribute to the conflict ([#6647](https://github.com/rubygems/bundler/pull/6647))
1993
2106
  - Avoid fetching and rebuilding git gems whenever any gem is changed in the Gemfile ([#6711](https://github.com/rubygems/bundler/pull/6711))
1994
- - Include the exact bundler version in the lock file in the suggested command when bundler warns about version mismatches of itself [#6971](https://github.com/rubygems/bundler/pull/6971)
2107
+ - Include the exact bundler version in the lockfile in the suggested command when bundler warns about version mismatches of itself [#6971](https://github.com/rubygems/bundler/pull/6971)
1995
2108
  - Fix plugins being installed every time a command is run #[#6978](https://github.com/rubygems/bundler/pull/6978)
1996
2109
  - Fallback to sequentially fetching specs on 429s [#6728](https://github.com/rubygems/bundler/pull/6728)
1997
2110
  - Make `bundle clean` also clean native extensions for gems with a git source [#7058](https://github.com/rubygems/bundler/pull/7058)
@@ -3456,7 +3569,7 @@ Changes
3456
3569
 
3457
3570
  ## Bug fixes:
3458
3571
 
3459
- - Revert gem source sorting in lock files (@indirect)
3572
+ - Revert gem source sorting in lockfiles (@indirect)
3460
3573
 
3461
3574
  # 1.7.1 (August 20, 2014)
3462
3575
 
@@ -3556,7 +3669,7 @@ Changes
3556
3669
  - redirects across hosts now work on rubies without OpenSSL ([#2686](https://github.com/rubygems/bundler/issues/2686), @grddev)
3557
3670
  - gemspecs now handle filenames with newlines ([#2634](https://github.com/rubygems/bundler/issues/2634), @jasonmp85)
3558
3671
  - support escaped characters in usernames and passwords (@punkie)
3559
- - no more exception on `update GEM` without lock file (@simi)
3672
+ - no more exception on `update GEM` without lockfile (@simi)
3560
3673
  - allow long config values ([#2823](https://github.com/rubygems/bundler/issues/2823), @kgrz)
3561
3674
  - cache successfully even locked to gems shipped with Ruby ([#2869](https://github.com/rubygems/bundler/issues/2869), @aughr)
3562
3675
  - respect NO_PROXY even if a proxy is configured ([#2878](https://github.com/rubygems/bundler/issues/2878), @stlay)
@@ -3704,7 +3817,7 @@ Changes
3704
3817
 
3705
3818
  ## Bug fixes:
3706
3819
 
3707
- - make gemspec path option preserve relative paths in lock file (@bwillis)
3820
+ - make gemspec path option preserve relative paths in lockfile (@bwillis)
3708
3821
  - use umask when creating binstubs ([#1618](https://github.com/rubygems/bundler/issues/1618), @v-yarotsky)
3709
3822
  - warn if graphviz is not installed ([#2435](https://github.com/rubygems/bundler/issues/2435), @Agis-)
3710
3823
  - show git errors while loading gemspecs
@@ -4593,7 +4706,7 @@ Changes
4593
4706
  - Skeleton gemspec now works with older versions of git
4594
4707
  - Fix shell quoting and ref fetching in GemHelper
4595
4708
  - Disable colored output in --deployment
4596
- - Preserve line endings in lock file
4709
+ - Preserve line endings in lockfile
4597
4710
 
4598
4711
  ## Features:
4599
4712
 
data/README.md CHANGED
@@ -41,7 +41,7 @@ To get in touch with the Bundler core team and other Bundler users, please join
41
41
 
42
42
  ### Contributing
43
43
 
44
- If you'd like to contribute to Bundler, that's awesome, and we <3 you. We've put together [the Bundler contributor guide](https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/README.md) with all of the information you need to get started.
44
+ If you'd like to contribute to Bundler, that's awesome, and we <3 you. We've put together [the Bundler contributor guide](https://github.com/rubygems/rubygems/blob/master/doc/bundler/contributing/README.md) with all of the information you need to get started.
45
45
 
46
46
  If you'd like to request a substantial change to Bundler or its documentation, refer to the [Bundler RFC process](https://github.com/rubygems/rfcs) for more information.
47
47
 
@@ -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 = "2025-01-16".freeze
8
- @git_commit_sha = "3c7c4ff2d8f".freeze
7
+ @built_at = "1980-01-02".freeze
8
+ @git_commit_sha = "8a2a14d63da".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -126,7 +126,7 @@ module Bundler
126
126
  end
127
127
 
128
128
  def removable?
129
- type == :lock || type == :gem
129
+ [:lock, :gem].include?(type)
130
130
  end
131
131
 
132
132
  def ==(other)
@@ -190,7 +190,7 @@ module Bundler
190
190
  def replace(spec, checksum)
191
191
  return unless checksum
192
192
 
193
- lock_name = spec.name_tuple.lock_name
193
+ lock_name = spec.lock_name
194
194
  @store_mutex.synchronize do
195
195
  existing = fetch_checksum(lock_name, checksum.algo)
196
196
  if !existing || existing.same_source?(checksum)
@@ -201,10 +201,12 @@ module Bundler
201
201
  end
202
202
  end
203
203
 
204
- def register(spec, checksum)
205
- return unless checksum
204
+ def missing?(spec)
205
+ @store[spec.lock_name].nil?
206
+ end
206
207
 
207
- register_checksum(spec.name_tuple.lock_name, checksum)
208
+ def register(spec, checksum)
209
+ register_checksum(spec.lock_name, checksum)
208
210
  end
209
211
 
210
212
  def merge!(other)
@@ -216,9 +218,9 @@ module Bundler
216
218
  end
217
219
 
218
220
  def to_lock(spec)
219
- lock_name = spec.name_tuple.lock_name
221
+ lock_name = spec.lock_name
220
222
  checksums = @store[lock_name]
221
- if checksums
223
+ if checksums&.any?
222
224
  "#{lock_name} #{checksums.values.map(&:to_lock).sort.join(",")}"
223
225
  else
224
226
  lock_name
@@ -229,11 +231,15 @@ module Bundler
229
231
 
230
232
  def register_checksum(lock_name, checksum)
231
233
  @store_mutex.synchronize do
232
- existing = fetch_checksum(lock_name, checksum.algo)
233
- if existing
234
- merge_checksum(lock_name, checksum, existing)
234
+ if checksum
235
+ existing = fetch_checksum(lock_name, checksum.algo)
236
+ if existing
237
+ merge_checksum(lock_name, checksum, existing)
238
+ else
239
+ store_checksum(lock_name, checksum)
240
+ end
235
241
  else
236
- store_checksum(lock_name, checksum)
242
+ init_checksum(lock_name)
237
243
  end
238
244
  end
239
245
  end
@@ -243,7 +249,11 @@ module Bundler
243
249
  end
244
250
 
245
251
  def store_checksum(lock_name, checksum)
246
- (@store[lock_name] ||= {})[checksum.algo] = checksum
252
+ init_checksum(lock_name)[checksum.algo] = checksum
253
+ end
254
+
255
+ def init_checksum(lock_name)
256
+ @store[lock_name] ||= {}
247
257
  end
248
258
 
249
259
  def fetch_checksum(lock_name, algo)
@@ -20,9 +20,14 @@ module Bundler
20
20
  require name
21
21
  get_constant(name)
22
22
  rescue LoadError
23
- Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
24
- require "irb"
25
- get_constant("irb")
23
+ if name == "irb"
24
+ Bundler.ui.error "#{name} is not available"
25
+ exit 1
26
+ else
27
+ Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
28
+ name = "irb"
29
+ retry
30
+ end
26
31
  end
27
32
 
28
33
  def get_constant(name)
@@ -32,9 +37,6 @@ module Bundler
32
37
  "irb" => :IRB,
33
38
  }[name]
34
39
  Object.const_get(const_name)
35
- rescue NameError
36
- Bundler.ui.error "Could not find constant #{const_name}"
37
- exit 1
38
40
  end
39
41
  end
40
42
  end
@@ -0,0 +1,167 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rbconfig"
4
+ require "shellwords"
5
+
6
+ module Bundler
7
+ class CLI::Doctor::Diagnose
8
+ DARWIN_REGEX = /\s+(.+) \(compatibility /
9
+ LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/
10
+
11
+ attr_reader :options
12
+
13
+ def initialize(options)
14
+ @options = options
15
+ end
16
+
17
+ def otool_available?
18
+ Bundler.which("otool")
19
+ end
20
+
21
+ def ldd_available?
22
+ Bundler.which("ldd")
23
+ end
24
+
25
+ def dylibs_darwin(path)
26
+ output = `/usr/bin/otool -L #{path.shellescape}`.chomp
27
+ dylibs = output.split("\n")[1..-1].filter_map {|l| l.match(DARWIN_REGEX)&.match(1) }.uniq
28
+ # ignore @rpath and friends
29
+ dylibs.reject {|dylib| dylib.start_with? "@" }
30
+ end
31
+
32
+ def dylibs_ldd(path)
33
+ output = `/usr/bin/ldd #{path.shellescape}`.chomp
34
+ output.split("\n").filter_map do |l|
35
+ match = l.match(LDD_REGEX)
36
+ next if match.nil?
37
+ match.captures[0]
38
+ end
39
+ end
40
+
41
+ def dylibs(path)
42
+ case RbConfig::CONFIG["host_os"]
43
+ when /darwin/
44
+ return [] unless otool_available?
45
+ dylibs_darwin(path)
46
+ when /(linux|solaris|bsd)/
47
+ return [] unless ldd_available?
48
+ dylibs_ldd(path)
49
+ else # Windows, etc.
50
+ Bundler.ui.warn("Dynamic library check not supported on this platform.")
51
+ []
52
+ end
53
+ end
54
+
55
+ def bundles_for_gem(spec)
56
+ Dir.glob("#{spec.full_gem_path}/**/*.bundle")
57
+ end
58
+
59
+ def lookup_with_fiddle(path)
60
+ require "fiddle"
61
+ Fiddle.dlopen(path)
62
+ false
63
+ rescue Fiddle::DLError
64
+ true
65
+ end
66
+
67
+ def check!
68
+ require_relative "../check"
69
+ Bundler::CLI::Check.new({}).run
70
+ end
71
+
72
+ def diagnose_ssl
73
+ require_relative "ssl"
74
+ Bundler::CLI::Doctor::SSL.new({}).run
75
+ end
76
+
77
+ def run
78
+ Bundler.ui.level = "warn" if options[:quiet]
79
+ Bundler.settings.validate!
80
+ check!
81
+ diagnose_ssl if options[:ssl]
82
+
83
+ definition = Bundler.definition
84
+ broken_links = {}
85
+
86
+ definition.specs.each do |spec|
87
+ bundles_for_gem(spec).each do |bundle|
88
+ bad_paths = dylibs(bundle).select do |f|
89
+ lookup_with_fiddle(f)
90
+ end
91
+ if bad_paths.any?
92
+ broken_links[spec] ||= []
93
+ broken_links[spec].concat(bad_paths)
94
+ end
95
+ end
96
+ end
97
+
98
+ permissions_valid = check_home_permissions
99
+
100
+ if broken_links.any?
101
+ message = "The following gems are missing OS dependencies:"
102
+ broken_links.flat_map do |spec, paths|
103
+ paths.uniq.map do |path|
104
+ "\n * #{spec.name}: #{path}"
105
+ end
106
+ end.sort.each {|m| message += m }
107
+ raise ProductionError, message
108
+ elsif permissions_valid
109
+ Bundler.ui.info "No issues found with the installed bundle"
110
+ end
111
+ end
112
+
113
+ private
114
+
115
+ def check_home_permissions
116
+ require "find"
117
+ files_not_readable = []
118
+ files_not_readable_and_owned_by_different_user = []
119
+ files_not_owned_by_current_user_but_still_readable = []
120
+ broken_symlinks = []
121
+ Find.find(Bundler.bundle_path.to_s).each do |f|
122
+ if !File.exist?(f)
123
+ broken_symlinks << f
124
+ elsif !File.readable?(f)
125
+ if File.stat(f).uid != Process.uid
126
+ files_not_readable_and_owned_by_different_user << f
127
+ else
128
+ files_not_readable << f
129
+ end
130
+ elsif File.stat(f).uid != Process.uid
131
+ files_not_owned_by_current_user_but_still_readable << f
132
+ end
133
+ end
134
+
135
+ ok = true
136
+
137
+ if broken_symlinks.any?
138
+ Bundler.ui.warn "Broken links exist in the Bundler home. Please report them to the offending gem's upstream repo. These files are:\n - #{broken_symlinks.join("\n - ")}"
139
+
140
+ ok = false
141
+ end
142
+
143
+ if files_not_owned_by_current_user_but_still_readable.any?
144
+ Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
145
+ "user, but are still readable. These files are:\n - #{files_not_owned_by_current_user_but_still_readable.join("\n - ")}"
146
+
147
+ ok = false
148
+ end
149
+
150
+ if files_not_readable_and_owned_by_different_user.any?
151
+ Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
152
+ "user, and are not readable. These files are:\n - #{files_not_readable_and_owned_by_different_user.join("\n - ")}"
153
+
154
+ ok = false
155
+ end
156
+
157
+ if files_not_readable.any?
158
+ Bundler.ui.warn "Files exist in the Bundler home that are not " \
159
+ "readable by the current user. These files are:\n - #{files_not_readable.join("\n - ")}"
160
+
161
+ ok = false
162
+ end
163
+
164
+ ok
165
+ end
166
+ end
167
+ end