Skip to content

Commit 20a6330

Browse files
committed
Improve libyaml source downloading error messages
People trying to build CRuby by following the instructions in its [README] have been running into [errors] due to missing `libyaml` on their system. Let's try to present a better error message when it happens. [README]: https://github.com/ruby/ruby/tree/fb5aa31e2d20ea8e1425432672f4de4c8ca2c26b#how-to-compile-and-install [errors]: #552
1 parent ca1b131 commit 20a6330

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ext/psych/extconf.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@
1919
# search the latest libyaml source under $srcdir
2020
yaml_source = Dir.glob("#{$srcdir}/yaml{,-*}/").max_by {|n| File.basename(n).scan(/\d+/).map(&:to_i)}
2121
unless yaml_source
22-
require_relative '../../tool/extlibs.rb'
23-
extlibs = ExtLibs.new(cache_dir: File.expand_path("../../tmp/download_cache", $srcdir))
24-
unless extlibs.process_under($srcdir)
25-
raise "failed to download libyaml source"
22+
download_failure = "failed to download libyaml source"
23+
begin
24+
require_relative '../../tool/extlibs.rb'
25+
extlibs = ExtLibs.new(cache_dir: File.expand_path("../../tmp/download_cache", $srcdir))
26+
unless extlibs.process_under($srcdir)
27+
raise download_failure
28+
end
29+
rescue
30+
# Implicitly captures Exception#cause. Newer rubies show it in the backtrace.
31+
raise download_failure
2632
end
2733
yaml_source, = Dir.glob("#{$srcdir}/yaml-*/")
2834
raise "libyaml not found" unless yaml_source

0 commit comments

Comments
 (0)