Skip to content

Commit 4464cbe

Browse files
rwstaunerhsbt
authored andcommitted
[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. rubygems/rubygems@de9dc2bdc4
1 parent af79914 commit 4464cbe

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/bundler/cli/doctor/diagnose.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def ldd_available?
2424

2525
def dylibs_darwin(path)
2626
output = `/usr/bin/otool -L #{path.shellescape}`.chomp
27-
dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
27+
dylibs = output.split("\n")[1..-1].filter_map {|l| l.match(DARWIN_REGEX)&.match(1) }.uniq
2828
# ignore @rpath and friends
2929
dylibs.reject {|dylib| dylib.start_with? "@" }
3030
end

spec/bundler/commands/doctor_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
expect(@stdout.string).to include("No issues")
6363
end
6464

65+
it "parses otool output correctly" do
66+
doctor = Bundler::CLI::Doctor::Diagnose.new({})
67+
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)")
68+
expect(doctor.dylibs_darwin("fake")).to eq(["/usr/lib/libSystem.B.dylib"])
69+
end
70+
6571
it "exits with a message if one of the linked libraries is missing" do
6672
doctor = Bundler::CLI::Doctor::Diagnose.new({})
6773
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/myrack/myrack.bundle"]

0 commit comments

Comments
 (0)