Provide a simple way to build / install Ruby from source on macOS.
-
Install
Xcode
/Command Line Tools
(fromxcode-select --install
) -
Setup environment variables:
export PATH="/Library/Developer/CommandLineTools/usr/bin:${PATH}"
export CC=clang
export CXX=clang++
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk
- Create directory
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/AppleInternal
to build Ruby foruniversal
architecture withoutld
deprecated warning
# Prepare the installation target
sudo mkdir -p /Library/Frameworks/Ruby.framework/Versions
( cd /Library/Frameworks/Ruby.framework && sudo chown :admin Versions && sudo chmod g+w Versions )
# Use the stable release
git clone --depth=1 https://github.com/thachnn/ruby4mac-builder.git
cd ruby4mac-builder
./build.sh --version=2.7.6 --prefix=/Library/Frameworks/Ruby.framework/Versions/2.7 \
--scratch-path=/usr/local/src --with-openssl=1.1.1n --with-gdbm=1.23 --unit-test
# Setup environments
sudo ln -s /Library/Frameworks/Ruby.framework/Versions/2.7/lib/ruby/gems/2.7.0 /Library/Ruby/Gems/
sudo ln -s /Library/Frameworks/Ruby.framework/Versions/2.7/bin/* /usr/local/bin/
- Install Ruby 2.7.5 with GDBM and RDoc for
universal
architecture (replace--enable-install-rdoc
with--with-rdoc=ri,html
if you want to install HTML RDoc)
./build.sh --prefix=/Library/Frameworks/Ruby.framework/Versions/2.7 \
--scratch-path=/usr/local/src --with-gdbm=1 --with-universal --extra-opts=--enable-install-rdoc
- Build Ruby 2.6.8 as portable package (
--with-static-linked-ext
is optional)
./build.sh --version=2.6.8 --prefix=/opt/local --scratch-path=/usr/local/src \
--with-gdbm=1.20 --with-universal --enable-rpath --extra-opts=--with-static-linked-ext --unit-test
# Cleanup
find /opt/local/{include,lib/pkgconfig} -depth 1 ! -name 'ruby*' -exec rm -rfv {} +
rm -fv /opt/local/lib/*.la
- Build Ruby 2.7.6 using
LibreSSL
andlibedit
from OS (without GDBM extension)
./build.sh --version=2.7.6 --prefix=/Library/Frameworks/Ruby.framework/Versions/2.7 \
--scratch-path=/usr/local/src --without-openssl --without-readline --extra-opts=--with-out-ext=gdbm
- Build Ruby 2.4.10 using
LibreSSL
/OpenSSL
andlibedit
from OS
./build.sh --version=2.4.10 --prefix=/Library/Frameworks/Ruby.framework/Versions/2.4 \
--scratch-path=/usr/local/src --without-openssl --without-readline --with-gdbm=1.18.1 --unit-test
This project also contains autotools
for macOS builder (pkg-config
, m4
, autoconf
, automake
, libtool
)
./build_autotools.sh --prefix=/opt/local --scratch-path=/usr/local/src --with-m4=1 \
--with-autoconf=2.71 --with-automake=1.16.5 --with-libtool=2.4.7 --unit-test --with-brew-pc