This guide details the steps needed to successfully install Ruby 3.4.7 on Apple Silicon Macs (M1/M2), which has some known compatibility issues during compilation.
First, ensure your system is ready:
# Update Homebrew
brew update && brew upgrade
# Install build dependencies
brew install openssl readline libyaml gmp- Update environment variables to use symlinked paths for resilience:
# Add these to your ~/.bash_profile, ~/.zshrc, or appropriate shell config
export LDFLAGS="-L/opt/homebrew/opt/openblas/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openblas/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig:$PKG_CONFIG_PATH"- Install rbenv and ruby-build if not already installed:
brew install rbenv ruby-build- Install Ruby 3.4.7 with specific configuration:
# Configure with proper flags to handle ARM64 build issues
env LDFLAGS="-L/opt/homebrew/lib" CPPFLAGS="-I/opt/homebrew/include" \
rbenv install 3.4.7 --verboseIf the rbenv installation still fails, you'll need to build from source with patches:
- Download Ruby 3.4.7 source:
cd /tmp
curl -O https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.7.tar.gz
tar -xzf ruby-3.4.7.tar.gz
cd ruby-3.4.7- Configure and patch build scripts:
./configure --prefix=/Users/$(whoami)/.rbenv/versions/3.4.7 \
--with-coroutine=ucontext \
--disable-dtrace \
--disable-profiling- Apply patches to mkconfig.rb due to ARM64-specific build issues:
# Patch the script to handle missing architecture information
sed -i.bak "s/arch = \$arch or raise \"missing -arch\"/arch = \$arch || ENV['arch'] || 'arm64-darwin25'/" tool/mkconfig.rb
sed -i.bak2 "s/version = \$version or raise \"missing -version\"/version = \$version || ENV['version'] || '3.4.7'/" tool/mkconfig.rb- Build and install:
make -j$(nproc || sysctl -n hw.ncpu)
make install- Refresh rbenv:
rbenv rehash
rbenv install 3.4.7 --verbose # To register the manually installed version- Cause: Ruby build script can't determine architecture on ARM64
- Solution: Apply patches to
mkconfig.rbas shown above
- Cause: Environment variables point to old OpenBLAS version
- Solution: Use symlinked paths (
/opt/homebrew/opt/openblas/lib) instead of versioned paths
- Cause: Known issue with Ruby 3.4.7 on ARM64 with certain gems
- Solution: This affects runtime with gems like concurrent-ruby, but installation is successful
After installation:
# Check Ruby version
rbenv global 3.4.7
ruby -v
# Test basic functionality
ruby -e "puts 'Ruby 3.4.7 installed successfully!'"- Ruby 3.4.7 builds successfully on ARM64 but has known compatibility issues with the
concurrent-rubygem causing segmentation faults in some applications - The build process patches internal Ruby build scripts to fix ARM64-specific issues
- Using symlinked paths in environment variables ensures resilience to Homebrew package updates
- For production use, consider Ruby 3.4.1 which is functionally very similar and more stable on ARM64