Skip to content

Instantly share code, notes, and snippets.

@shrwnsan
Forked from brentertz/rvm2rbenv.txt
Last active May 12, 2020 08:19
Show Gist options
  • Save shrwnsan/9570ba72802b7e3f2b27 to your computer and use it in GitHub Desktop.
Save shrwnsan/9570ba72802b7e3f2b27 to your computer and use it in GitHub Desktop.
Migration from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
sudo rm -rf ~/.rvm
sudo rm -rf ~/.rvmrc
sudo rm -rf /etc/rvmrc
# Also, please check all .bashrc .bash_profile .profile and .zshrc for RVM source lines and delete or comment out if this was a Per-User installation.
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
brew install rbenv
brew install rbenv-gem-rehash
brew install ruby-build
## Config ####################################################################
# Global git ignore
git config --global core.excludesfile ~/.gitignore_global
printf "vendor/bundle\n.DS_Store\n" >> ~/.gitignore_global
# 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 -)"' >> ~/.bash_profile
# Remove the RVM stuff from your .profile - It probably looks like...
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
# Add RBENV to PATH in your .profile
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
# Reload shell
exec $SHELL -l
# 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
rbenv install 1.9.3-p429
# Rehash rbenv shims (run this after installing binaries)
rbenv rehash #Might not have to anymore if rbenv-gem-rehash was installed
# Set the global Ruby version
rbenv global 1.9.3-p429
# Update to the latest Rubygems version and install bundler globally
gem update --system
gem install bundler --pre
# Install gems critical to Rails development, e.g.
gem install foreman pg rails thin --no-rdoc --no-ri
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/...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment