RBEnv, Ubuntu and Bundler

Feb 10, 2013

A how-to for setting up ubuntu 18 for ruby on rails development

You want to checkout rbenv and the plugin ruby-build:

cd ~/
git clone git:// .rbenv
git clone git:// ~/.rbenv/plugins/ruby-build

Then add it to your path so it actually runs ruby versions installed by rbenv

echo 'export PATH="$PATH:$HOME/.rbenv/bin"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

To setup your build environment you'll need these

sudo apt-get install -y libssl-dev libreadline-dev zlib1g-dev libsqlite3-dev nodejs

Then use rbenv to install a version of ruby and set it as global

rbenv install 2.5.3
rbenv global 2.5.3

Now this should show you the ruby version

ruby -v

The step other howto's forget; you want to develop in rails right? Then you'll want to install rails in global gems

gem install rails

Alias Goodness

I've been really enjoying these commands to shortcut using bundler exec before everything add these to your ~/.bashrc

alias b="bundle"
alias bi="b install --path vendor"
alias bu="b update"

Older Rubies

If you are installing older versions of ruby on a modern linux like ubuntu 18, you're going to run into GCC compiling issues with errors like ubuntu ruby 2.3.3 moifier ignored since 'D'. This happens because the modern linux uses GCC 7. So lets deal with gcc compatibility issues so we can build older versions of ruby.

sudo apt-get install gcc-6 g++-6 g++-6-multilib gfortran-6

Then install your older ruby like this

CC=/usr/bin/gcc-6 rbenv install 2.3.3

And you're all set

Read more on rbenv and bundler