Skip to content

Instantly share code, notes, and snippets.

@madwork
Last active Apr 5, 2019
Embed
What would you like to do?
Compile Ruby
/*
!.gitignore
!ruby-build.sh
#!/bin/bash
export LDFLAGS='-L/usr/local/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/libxml2/lib -L/usr/local/opt/curl/lib -L/usr/local/opt/libiconv/lib -L/usr/local/opt/mysql@5.7/lib'
export CPPFLAGS='-I/usr/local/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/opt/libxml2/include -I/usr/local/opt/curl/include -I/usr/local/opt/libiconv/include -I/usr/local/opt/mysql@5.7/include'
export ARCHFLAGS='-arch x86_64'
export CFLAGS='-g -O2'
read -p 'RUBY_VERSION: ' RUBY_VERSION
read -p 'RUBY_SHA256: ' RUBY_SHA256
cd $HOME/code/ruby-build
curl -L -O -C - https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION:0:3}/ruby-${RUBY_VERSION}.tar.gz
echo "${RUBY_SHA256} ruby-${RUBY_VERSION}.tar.gz" > ruby-${RUBY_VERSION}.tar.gz.sha256
if ! shasum -c ruby-${RUBY_VERSION}.tar.gz.sha256; then
exit 1
fi
rm -rf ruby-${RUBY_VERSION}
tar zxf ruby-${RUBY_VERSION}.tar.gz
cd ruby-${RUBY_VERSION}
./configure --disable-install-doc --enable-shared --prefix=$HOME/.rubies/ruby-${RUBY_VERSION}
make
make install
echo ruby-${RUBY_VERSION}
/usr/local/bin/chruby-exec ruby-${RUBY_VERSION} -- gem update --system --no-document
/usr/local/bin/chruby-exec ruby-${RUBY_VERSION} -- gem install bundler pry awesome_print --no-document
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment