ruby-changes:71625
From: Alan <ko1@a...>
Date: Tue, 5 Apr 2022 08:56:38 +0900 (JST)
Subject: [ruby-changes:71625] 18044f4fbb (master): [ruby/psych] Improve libyaml source downloading error messages
https://git.ruby-lang.org/ruby.git/commit/?id=18044f4fbb From 18044f4fbbfdef27b1e41c109d63c276026008c5 Mon Sep 17 00:00:00 2001 From: Alan Wu <XrXr@u...> Date: Mon, 4 Apr 2022 14:10:29 -0400 Subject: [ruby/psych] 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]: https://github.com/ruby/psych/issues/552 https://github.com/ruby/psych/commit/20a633028e --- ext/psych/extconf.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb index 795a0506ff..b9cd12033d 100644 --- a/ext/psych/extconf.rb +++ b/ext/psych/extconf.rb @@ -19,10 +19,16 @@ if yaml_source == true https://github.com/ruby/ruby/blob/trunk/ext/psych/extconf.rb#L19 # search the latest libyaml source under $srcdir yaml_source = Dir.glob("#{$srcdir}/yaml{,-*}/").max_by {|n| File.basename(n).scan(/\d+/).map(&:to_i)} unless yaml_source - require_relative '../../tool/extlibs.rb' - extlibs = ExtLibs.new(cache_dir: File.expand_path("../../tmp/download_cache", $srcdir)) - unless extlibs.process_under($srcdir) - raise "failed to download libyaml source" + download_failure = "failed to download libyaml source" + begin + require_relative '../../tool/extlibs.rb' + extlibs = ExtLibs.new(cache_dir: File.expand_path("../../tmp/download_cache", $srcdir)) + unless extlibs.process_under($srcdir) + raise download_failure + end + rescue + # Implicitly captures Exception#cause. Newer rubies show it in the backtrace. + raise download_failure end yaml_source, = Dir.glob("#{$srcdir}/yaml-*/") raise "libyaml not found" unless yaml_source -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/