Skip to content

Instantly share code, notes, and snippets.

@greenbicycle
Forked from soardex/gist:e95cdc230d1ac5b824b3
Last active July 31, 2020 02:43
Show Gist options
  • Save greenbicycle/449bd8270aacc24a7ca9c1a24ae28676 to your computer and use it in GitHub Desktop.
Save greenbicycle/449bd8270aacc24a7ca9c1a24ae28676 to your computer and use it in GitHub Desktop.
Install ruby in Centos 7 with rbenv
# Adapted from this gist
# https://gist.github.com/soardex/e95cdc230d1ac5b824b3
# I changed .bash_profile to .bashrc since docker opens bash as non-login shell
# Also, I added 'gem update --system' because bundler was complaining about it
RUBY_VERSION=2.3.0
# install build dependencies
sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel \
libyaml-devel libffi-devel openssl-devel make bzip2 \
autoconf automake libtool bison curl sqlite-devel
# clone and install rbenv environment
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
# re-init bash
source ~/.bashrc
# install latest ruby
rbenv install -v $RUBY_VERSION
# sets the default ruby version that the shell will use
rbenv global $RUBY_VERSION
# to disable generating of documents as that would take so much time
echo "gem: --no-document" > ~/.gemrc
# bundler complained that this should be run.
gem update --system
# install bundler
gem install bundler
# must be executed everytime a gem has been installed in order for the ruby executable to run
rbenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment