Skip to content

Instantly share code, notes, and snippets.

@sauloefo
Last active November 27, 2023 07:48
Show Gist options
  • Save sauloefo/bd1d3e630c1ba27d7066290885b5cd31 to your computer and use it in GitHub Desktop.
Save sauloefo/bd1d3e630c1ba27d7066290885b5cd31 to your computer and use it in GitHub Desktop.
Setup Ruby on Rails development environment with asdf

TL;DR:

Copy and paste the instruction below in your BASH terminal.

It should work for any Ubuntu based distribution.

Your local user password will be required.

eval "$(wget -qO- https://gist.github.com/raw/bd1d3e630c1ba27d7066290885b5cd31/setup_ror_dev_environment_with_asdf.sh)"

Tested on:

  • Pop!OS_ 22.04
#!/bin/bash
set -euo pipefail
if [ `git --version &> /dev/null; echo $?` -ne '0' ]; then
echo '===> Installing git ...'
sudo apt install git -y
else
echo '===> Skipping git installation ...'
fi
echo "'git --version' output:"
git --version
if [ `curl --version &> /dev/null; echo $?` -ne '0' ]; then
echo '===> Installing curl ...'
sudo apt install curl -y
else
echo '===> Skipping curl installation ...'
fi
echo "'curl --version' output:"
curl --version
if [ `asdf --version &> /dev/null; echo $?` -ne '0' ]; then
echo '===> Installing asdf ...'
# clone asdf repository from github if it doesn't exist.
[ ! -d ~/.asdf ] && git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1
# ~/.asdf.init contains commands to initalize asdf.
echo '. "$HOME"/.asdf/asdf.sh' > ~/.asdf.init
echo '. "$HOME"/.asdf/completions/asdf.bash' >> ~/.asdf.init
# add call to .asdf.init if it doesn't exist in the .bashrc file
[ `grep -q '.asdf.init' ~/.bashrc; echo $?` -ne '0' ] && echo '. "$HOME"/.asdf.init' >> .bashrc
. ~/.asdf.init
else
echo '===> Skipping asdf installation ...'
fi
echo "'asdf --version' output:"
asdf --version
if [ `ruby --version &> /dev/null; echo $?` -ne '0' ]; then
echo '===> Installing ruby ...'
echo '...... Installing dependencies ...'
sudo apt install libssl-dev libyaml-dev -y
echo '...... Installing ruby using asdf ...'
asdf plugin add ruby
asdf install ruby latest
asdf global ruby latest
else
echo '===> Skipping ruby installation ...'
fi
echo "'ruby --version' output:"
ruby --version
if [ `sqlite3 --version &> /dev/null; echo $?` -ne '0' ]; then
echo '===> Installing sqlite3 ...'
sudo apt install sqlite3 -y
else
echo '===> Skipping sqlite3 installation ...'
fi
echo "'sqlite3 --version' output:"
sqlite3 --version
if [ `rails --version &> /dev/null; echo $?` -ne '0' ]; then
echo '===> Installing ruby on rails ...'
gem install rails
gem install foreman
else
echo '===> Skipping ruby on rails installation ...'
fi
echo "'rails --version' output:"
rails --version
asdf reshim
echo '===> Done!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment