Skip to content

Instantly share code, notes, and snippets.

@yaodong
Forked from crhan/rbenv-install-system-wide.sh
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaodong/01a835417bffd60c4491 to your computer and use it in GitHub Desktop.
Save yaodong/01a835417bffd60c4491 to your computer and use it in GitHub Desktop.
PREFIX="/usr/local"
RBENV_PREFIX="$PREFIX/rbenv"
BIN_PATH="$PREFIX/bin"
RBENV_GROUP="rbenv"
umask 002
## Install rbenv, ruby-build and rbenv-gem-rehash
git clone git://github.com/sstephenson/rbenv.git $RBENV_PREFIX
mkdir $RBENV_PREFIX/plugins
git clone git://github.com/sstephenson/ruby-build.git $RBENV_PREFIX/plugins/ruby-build
git clone git://github.com/sstephenson/rbenv-gem-rehash.git $RBENV_PREFIX/plugins/rbenv-gem-rehash
## add rbenv script to PATH
ln -s $RBENV_PREFIX/bin/rbenv $BIN_PATH/rbenv
## Add rbenv to the System wide profile:
## @note profiles only will be sourced in `login shell`,
## see the difference here(Chinese): https://gist.github.com/yegle/1564928
cat <<EOF > /etc/profile.d/rbenv.sh
# rbenv setup
export RBENV_ROOT=${RBENV_PREFIX}
eval "\$(rbenv init -)"
EOF
chmod +x /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh
## set rbenv group property
groupadd $RBENV_GROUP
chown -R :rbenv $RBENV_PREFIX
find $RBENV_PREFIX -type d -exec chmod g+Xs {} \;
## Install Ruby
#rbenv install 1.9.3-p484
#rbenv install 2.0.0-p353
#rbenv global 2.0.0-p353
## Rehash:
#rbenv rehash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment