From 4789ff8235a08cfc25805d9fb6dca4dd1df5c9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 7 Nov 2023 12:13:46 +0100 Subject: [PATCH] Instruct Ruby to fail the build if openssl or psych are missing Normally, Ruby `make` step will print a warning about any missing extensions, but will not abort the build and instead proceed as normal. Since Ruby installations without openssl or psych are essentially broken, ruby-build used to have a `verify_openssl` build step to test if the newly built Ruby can load these extensions, and print helpful information and abort the build on errors: Loading the Ruby openssl extension failed ERROR: Ruby install aborted due to missing extensions The `verify_opensl` implementation was necessary to provide a good experience for ruby-build users, but was hacky and I would prefer to eliminate it. It appears that passing `--with-ext=openssl,psych` to the Ruby configure step marks those extensions as mandatory and fails the `make` process if they failed to build. This is exactly the behavior we want, so this enables the configure option for all Ruby builds. --- bin/ruby-build | 47 ++++++---------------------------------------- test/build.bats | 42 ++++++++++++++++++++--------------------- test/compiler.bats | 2 +- 3 files changed, 27 insertions(+), 64 deletions(-) diff --git a/bin/ruby-build b/bin/ruby-build index 167b6d9952..eaec347d04 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -671,6 +671,10 @@ build_package_standard_build() { package_option ruby configure --with-openssl-dir="/usr/local" fi fi + if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-ext* ]]; then + # Fail the `make` step if any of these extensions were not compiled. + package_option ruby configure --with-ext=openssl,psych + fi fi ( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then @@ -1212,48 +1216,9 @@ build_package_openssl() { fi } -# Post-install check that the openssl extension was built. -# TODO: explore replacing this implementation with scanning the `make` log -# for the "Following extensions are not compiled" block. +# Kept for backward compatibility with 3rd-party definitions. build_package_verify_openssl() { - local msg - msg="->$(print_command "$RUBY_BIN" -e "