Build Ruby environment on Ubuntu

post on

from Gist: oriverk/


Install latest ver.

# install in one time
sudo apt install autoconf bison build-essential libssl-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev

# install rbenv
# rbenv is tool to manage a few of ruby versions and enable to change ruby ver. project by project.
git clone ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone "$(rbenv root)"/plugins/ruby-build

# Install ruby
rbenv install --list
rbenv install 2.x.x
rbenv global 2.x.x

# Instal yarn
# Rails6 needs webpacker, and Webpacker needs yarn to install
curl -sS | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn

# Install Rails
gem install rails --no-document

# install webpacker
# inner App
rails webpacker:install

Install by "apt install"

sudo apt install -y ruby ruby-dev build-essential
sudo apt install yarn

sudo gem install rails
  • "-y" means "All Yes"
  • build-essential contain information about package to build Debian pack.
    • If do not build Debian, build~ is not needed
    • Reference


Setup Reference