Node.js, PHP and APIs · Troubleshooting walkthrough
Ruby will not compile when you install it with asdf
Short answer
asdf install ruby prints BUILD FAILED when ruby-build, which asdf-ruby runs under the hood, cannot compile the psych or openssl extension. Read the build log, install the missing libyaml or OpenSSL headers (on macOS: brew install openssl@3 readline libyaml gmp autoconf), run asdf plugin update ruby and retry. Applies to Ruby 3.3 to 4.0 with asdf 0.20.
asdf install ruby does not compile Ruby itself. asdf-ruby hands the job to ruby-build, and ruby-build stops with BUILD FAILED when a required extension cannot be configured. The two it refuses to skip are psych (YAML) and openssl, so the failure is almost always a missing library header, not a Ruby bug.
The summary at the end of the build output is short and unhelpful. The useful part is in the log file ruby-build writes, which names the extension that failed.
The text you see
BUILD FAILED (Ubuntu 24.04 on x86_64 using ruby-build 20261119)*** Following extensions are not compiled:Could not be configured. It will not be installed.ruby-build: definition not found: 3.3.0
Stage 1
Read the extension block in the log
ruby-build prints the path of its log after the failure. Open the newest one and look for the block that lists extensions that were not compiled. Which extension is named decides everything that follows.
Find the failing extension
LOG="$(ls -t "${TMPDIR:-/tmp}"/ruby-build.*.log | head -1)"
grep -n -A6 "Following extensions are not compiled" "$LOG"| What the log shows | Likely cause | Go to |
|---|---|---|
| psych: Could not be configured | libyaml headers missing | libyaml |
| openssl: with a pointer to mkmf.log | OpenSSL headers missing or the wrong OpenSSL | OpenSSL |
| Several extensions on an Apple Silicon Mac | Intel Homebrew in /usr/local | Homebrew |
| No log, only definition not found | asdf-ruby is out of date | plugin |
Stage 2
libyaml: when psych cannot be configured
ruby-build passes --with-ext=openssl,psych,+ to Ruby's configure for Ruby 2.5 and newer. Without libyaml and its headers, psych cannot be configured, and the build stops rather than produce a Ruby that has no YAML support. ruby-build finds a Homebrew libyaml by itself.
Install the headers, then retry
# macOS
brew install libyaml
# Ubuntu or Debian
sudo apt-get install libyaml-dev
# Rocky Linux 9 (libyaml-devel lives in the CRB repository)
sudo dnf --enablerepo=crb install libyaml-devel
asdf install ruby 3.3.0Stage 3
OpenSSL: read mkmf.log, not the main output
ruby-build uses an OpenSSL it finds on the system and downloads its own copy only when it finds none, so a half-installed or clashing OpenSSL can still break the build. The real reason sits in ext/openssl/mkmf.log.
Install the development package for your system. With several versions installed, name one through RUBY_CONFIGURE_OPTS, which asdf-ruby passes to ruby-build. Ruby 3.0 and older need OpenSSL 1.1 rather than 3.
Show the reason, then point Ruby at one OpenSSL
find "${TMPDIR:-/tmp}" -path "*ext/openssl/mkmf.log" 2>/dev/null | head -1 | xargs tail -n 30
# macOS
brew install openssl@3
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@3)" asdf install ruby 3.3.0
# Ubuntu or Debian
sudo apt-get install libssl-devStage 4
Apple Silicon with an Intel Homebrew
The ruby-build wiki calls this the most common source of compile errors on Apple Silicon. A Mac migrated from an Intel machine can carry a Homebrew under /usr/local with libraries built for x86_64, and Ruby's extensions fail when they link against them. The check is whether brew config shows /usr/local or Rosetta 2: true on an arm64 machine.
Move to a native Homebrew in /opt/homebrew
brew config | grep -E "HOMEBREW_PREFIX|Rosetta 2"
brew bundle dump
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" -- --path=/usr/local
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/opt/homebrew/bin/brew bundle installAlso remove any arch -x86_64 brew alias from your shell files, or the old prefix comes back.
Stage 5
definition not found: update the plugin
If the command stops at once with ruby-build: definition not found and writes no log, nothing was compiled. asdf-ruby does not fetch new Ruby versions on its own, and its README names a missing version as the most common problem reported. The bundled ruby-build has no recipe for that release yet.
Refresh ruby-build, then install
asdf plugin update ruby
asdf install ruby 3.3.0Stage 6
Load psych and openssl in the new Ruby
A successful build should load both extensions that were at risk.
Load both extensions
"$(asdf where ruby 3.3.0)/bin/ruby" -rpsych -ropenssl -e 'puts "psych and openssl load"'If you only keep one thing
BUILD FAILEDmeans a required extension could not be built; the log names it.- psych needs libyaml headers, openssl needs OpenSSL headers, and
definition not foundneeds a plugin update. - On Apple Silicon, check that Homebrew lives in /opt/homebrew.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.