Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip passing --with-readline-dir for Ruby 3.3+ #2333

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,10 @@ build_package_standard() {
local PACKAGE_CFLAGS="${package_var_name}_CFLAGS"

if [ "$package_var_name" = "RUBY" ]; then
if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-readline-dir=* ]]; then
# shellcheck disable=SC2155
local ruby_semver="$(normalize_semver "${package_name#ruby-}")"
if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-readline-dir=* && "$ruby_semver" -lt 300300 ]]; then
# Ruby 3.3+ does not need external readline: https://github.com/rbenv/ruby-build/issues/2330
use_homebrew_readline || use_freebsd_readline || true
fi
if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-libffi-dir=* ]]; then
Expand All @@ -672,7 +675,7 @@ build_package_standard() {
# use openssl installed from Ports Collection
package_option ruby configure --with-openssl-dir="/usr/local"
fi
elif [ "$(normalize_semver "${package_name#ruby-}")" -lt 200707 ]; then
elif [ "$ruby_semver" -lt 200707 ]; then
local opt
for opt in $RUBY_CONFIGURE_OPTS "${RUBY_CONFIGURE_OPTS_ARRAY[@]}"; do
if [[ $opt == --with-openssl-dir=* ]]; then
Expand All @@ -690,7 +693,7 @@ build_package_standard() {
fi
if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-ext* &&
"$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--without-ext* &&
"$(normalize_semver "${package_name#ruby-}")" -ge 200500 ]]; then
"$ruby_semver" -ge 200500 ]]; then
# For Ruby 2.5+, fail the `make` step if any of these extensions were not compiled.
# Otherwise, the build would have succeeded, but Ruby would be useless at runtime.
# https://github.com/ruby/ruby/commit/b58a30e1c14e971adba4096104274d5d692492e9
Expand Down
24 changes: 24 additions & 0 deletions test/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,30 @@ make install
OUT
}

@test "readline is not auto-discovered for Ruby 3.3" {
cached_tarball "ruby-3.3.0" configure

readline_libdir="$TMP/homebrew-readline"
mkdir -p "$readline_libdir"

stub_repeated brew "--prefix readline : echo '$readline_libdir'"
stub_make_install

run_inline_definition <<DEF
install_package "ruby-3.3.0" "http://ruby-lang.org/ruby/3.0/ruby-3.3.0.tar.gz"
DEF
assert_success

unstub brew
unstub make

assert_build_log <<OUT
ruby-3.3.0: [--prefix=$INSTALL_ROOT,--with-ext=openssl,psych,+]
make -j 2
make install
OUT
}

@test "readline is not linked from Homebrew when explicitly defined" {
cached_tarball "ruby-3.2.0" configure

Expand Down