public
Last active

Switch from RVM to RBENV

  • Download Gist
rvm2rbenv.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
## Prepare ###################################################################
 
# Remove RVM
rvm implode
 
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
 
## Install ###################################################################
brew install rbenv
brew install ruby-build
 
## Config ####################################################################
 
# Global git ignore
git config --global core.excludesfile ~/.gitignore
printf "vendor/bundle\n.DS_Store\n" >> ~/.gitignore
 
# Set default bundle path
mkdir -p ~/.bundle
printf -- "---\nBUNDLE_PATH: vendor/bundle" >> ~/.bundle/config
 
# Instantiate rbenv with your shell (choose preferred file - .profile, .bash_profile, .zshrc, etc)
printf 'eval "$(rbenv init -)"' >> ~/.profile
 
# Remove the RVM stuff from your .profile - It probably looks like...
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
 
# Reload your profile
. ~/.profile
 
# Add autocompletion to IRB
touch ~/.irbrc
printf "require 'irb/completion'" >> ~/.irbrc
 
## Usage #####################################################################
rbenv
 
# Choose a ruby flavor version to install
rbenv install 1.9.3-p0
rbenv install 1.9.2-p290
 
# Rehash rbenv shims (run this after installing binaries)
rbenv rehash
 
# Set the global Ruby version and install bundler globally
rbenv global 1.9.3-p0
gem install bundler --pre
gem install OTHER_GLOBAL_GEMS # eg) Rails, Heroku, etc - NOTE: You need to do this for each ruby version.
rbenv rehash
 
# Set a project specific ruby version
cd myproject
rbenv local 1.9.2-p290
 
# Install gems in Gemfile to vendor/bundle
cd ~/projects/newhotness
bundle
 
# Start app in context of bundled gems
bundle exec rails s
 
## RubyMine Notes ############################################################
# Open settings | Ruby SDK & Gems
# Remove ALL RVM related SDK's
# Add new Ruby SDK for project - Find path by found by running `rbenv which ruby` in project directory
# Edit launch/debug configurations | Bundler - enable/check - Run the script in the context of bundler
# Note: RubyMine debugger will install some additional needed gems into your global gem path - eg) ~/.gem/ruby/...

Hello, you miss to set the PATH to rbenv in .profile.

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile

That path isn't part of rbenv.

Don't need pre-release version of bundler

To avoid rehashing all of the time, have a look at https://github.com/sstephenson/rbenv-gem-rehash

thanks.

this has solved so many headaches for me.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.