From 4a3ff7e194fe0e8fba394ef45415c6d053684bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 21 Nov 2023 17:08:36 +0100 Subject: [PATCH] Surface `make` problems while building Ruby extensions A very common type of build failure is that the Ruby "openssl" extension failed to compile. However, when that happens, ruby-build just prints a generic "BUILD FAILED" message. To find out what happened, the user would first have to open the ruby-build log, note the "Following extensions are not compiled" section, then figure out how to find the exact location to the "ext/openssl/mkmf.log" file for more information. Now, when `make` fails, ruby-build will automatically forward the "Following extensions are not compiled" information to stderr. --- bin/ruby-build | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 66de58a0a5..7c0179238a 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -692,9 +692,20 @@ build_package_standard_build() { "${!PACKAGE_CONFIGURE_OPTS_ARRAY}" $CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS} ) || return $? + local status=0 # make -j # shellcheck disable=SC2086 - capture_command "$MAKE" "${!PACKAGE_MAKE_OPTS_ARRAY}" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS} + capture_command "$MAKE" "${!PACKAGE_MAKE_OPTS_ARRAY}" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS} || status=$? + + if [[ $status -ne 0 && -z $VERBOSE ]]; then + # Surface any extension building problems from `make` log to stderr. + # https://github.com/ruby/ruby/blob/HEAD/ext/extmk.rb + sed -n '/Following extensions are not compiled/,/Fix the problems/p' "$LOG_PATH" | \ + sed '/remove these directories and try again/d' | \ + sed "s:\\([[:space:]]*Check\\) \\(ext/.*\\):\\1 ${PWD}/\\2:" >&2 + fi + + return $status } build_package_standard_install() {