summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandy Stauner <randy.stauner@shopify.com>2025-04-29 11:30:05 -0700
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-05-12 11:09:22 +0900
commit4464cbe5cd17cff26b4aceee83c849790b812c8b (patch)
tree2bceafb45e51d49d52924bc4afcfdc8e868602c2
parentaf799140028d9600c5c799356da9a4f1f31b2e7e (diff)
[rubygems/rubygems] Fix doctor command parsing of otool output
I have several gem dylibs that have a line matching "(compatibility " with no file path preceding it. https://github.com/rubygems/rubygems/commit/de9dc2bdc4
-rw-r--r--lib/bundler/cli/doctor/diagnose.rb2
-rw-r--r--spec/bundler/commands/doctor_spec.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/bundler/cli/doctor/diagnose.rb b/lib/bundler/cli/doctor/diagnose.rb
index c5da23acb8..a878025dda 100644
--- a/lib/bundler/cli/doctor/diagnose.rb
+++ b/lib/bundler/cli/doctor/diagnose.rb
@@ -24,7 +24,7 @@ module Bundler
def dylibs_darwin(path)
output = `/usr/bin/otool -L #{path.shellescape}`.chomp
- dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
+ dylibs = output.split("\n")[1..-1].filter_map {|l| l.match(DARWIN_REGEX)&.match(1) }.uniq
# ignore @rpath and friends
dylibs.reject {|dylib| dylib.start_with? "@" }
end
diff --git a/spec/bundler/commands/doctor_spec.rb b/spec/bundler/commands/doctor_spec.rb
index 456fb4ec78..5ceaf37f29 100644
--- a/spec/bundler/commands/doctor_spec.rb
+++ b/spec/bundler/commands/doctor_spec.rb
@@ -62,6 +62,12 @@ RSpec.describe "bundle doctor" do
expect(@stdout.string).to include("No issues")
end
+ it "parses otool output correctly" do
+ doctor = Bundler::CLI::Doctor::Diagnose.new({})
+ expect(doctor).to receive(:`).with("/usr/bin/otool -L fake").and_return("/home/gem/ruby/3.4.3/gems/blake3-rb-1.5.4.4/lib/digest/blake3/blake3_ext.bundle:\n\t (compatibility version 0.0.0, current version 0.0.0)\n\t/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)")
+ expect(doctor.dylibs_darwin("fake")).to eq(["/usr/lib/libSystem.B.dylib"])
+ end
+
it "exits with a message if one of the linked libraries is missing" do
doctor = Bundler::CLI::Doctor::Diagnose.new({})
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/myrack/myrack.bundle"]