Skip to content

Commit

Permalink
Surface make problems while building Ruby extensions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mislav committed Nov 21, 2023
1 parent 4cb2857 commit 4a3ff7e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,20 @@ build_package_standard_build() {
"${!PACKAGE_CONFIGURE_OPTS_ARRAY}" $CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS}
) || return $?

local status=0
# make -j <num_cpu_cores>
# 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() {
Expand Down

0 comments on commit 4a3ff7e

Please sign in to comment.