Skip to content

Instantly share code, notes, and snippets.

@milmih
Created August 23, 2014 09:52
Show Gist options
  • Save milmih/7beff4ad87cbef0a0e36 to your computer and use it in GitHub Desktop.
Save milmih/7beff4ad87cbef0a0e36 to your computer and use it in GitHub Desktop.
Setting rbenv up globally
#!/usr/bin/env bash
if [ "$UID" -ne 0 ]
then echo "Please run this script as root user"
exit
fi
apt-get -y update
apt-get -y upgrade
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev git sqlite3 libsqlite3-dev
git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
mkdir /usr/local/rbenv/plugins
git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins
cat <<EOF >> /etc/skel/.bashrc
#### begin rbenv configuration ####
## Remove these lines if you wish to use your own
## clone of rbenv (with your own rubies)
export RBENV_ROOT=/usr/local/rbenv
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
# Allow local Gem management
export GEM_HOME="$HOME/.gem"
export GEM_PATH="$HOME/.gem"
export PATH="$HOME/.gem/bin:$PATH"
#### end rbenv configuration ####
EOF
cat <<EOF >> ~/.bashrc
#### begin rbenv configuration ####
## Remove these lines if you wish to use your own
## clone of rbenv (with your own rubies)
export RBENV_ROOT=/usr/local/rbenv
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
#### end rbenv configuration ####
EOF
source ~/.bashrc
rbenv install 2.1.2
rbenv rehash
rbenv global 2.1.2
gem install rbenv-rehash --no-ri --no-rdocp
echo "gem: --no-rdoc --no-ri" > ~/.gemrc
@jefft
Copy link

jefft commented Jan 13, 2017

If /usr/local/rbenv/plugins is empty, then the command:

git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins

leaves the contents of ruby-build/ directly in the plugins/ directory. It's safer to just use:

git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment