Skip to content

Instantly share code, notes, and snippets.

@brycejohnston
Last active July 22, 2020 00:35
Show Gist options
  • Save brycejohnston/76a4288f24374d59c6518ff7c7072b66 to your computer and use it in GitHub Desktop.
Save brycejohnston/76a4288f24374d59c6518ff7c7072b66 to your computer and use it in GitHub Desktop.
Ubuntu 20.04 Ruby and Elixir Development Setup

Ubuntu 20.04 Ruby and Elixir (and Misc) Development Setup

Guide to setting up a new Ubuntu 20.04 dev environment with Ruby, Elixir and Node.js installed with the asdf version management tool along with PostgreSQL & PostGIS.

Update system and install prerequisite packages

Some of these packages may already be installed

sudo apt-get install autoconf automake binutils build-essential curl \
 dirmngr dnsutils fonts-liberation fonts-liberation2 fontconfig g++ gcc gdal-bin git \
 gnupg htop imagemagick libaio-dev libacl1-dev libbz2-dev libcurl4-openssl-dev libevent-dev \
 libexpat1-dev libffi-dev libgdal-dev libgeos-3.8.0 libgeos-dev libgeos++-dev \
 libjpeg-turbo8 libjpeg-turbo8-dev liblzma-dev libmapnik-dev libncurses-dev \
 libpcre3-dev libproj-dev libpq-dev libreadline-dev libssl-dev libtool libxml2-dev \
 libxml2-utils libxrender1 libxslt-dev libxslt1-dev libyaml-dev make mapnik-utils \
 nginx ntp openssl postfix postgresql-12 postgresql-12-postgis-3 \
 python3-dev python3-gdal python3-pip python3-numpy python3-numpy python3-pip \
 python3-setuptools redis-server software-properties-common sudo tmux ufw unixodbc-dev unzip \
 vim wget xfonts-75dpi xfonts-base xsltproc zip zlib1g-dev p7zip-full \
 automake autoconf libreadline-dev libncurses-dev libncurses5-dev \
 libssl-dev libyaml-dev libxslt-dev libffi-dev libtool unixodbc-dev \
 libwxgtk3.0-gtk3-dev libgl1-mesa-dev  libglu1-mesa-dev libssh-dev xsltproc fop \
 libxml2-utils wget tmux vim emacs bison libgdbm6 libgdbm-dev inotify-tools

When postfix install prompt shows up (Choose internet site configuration and use the computers name)

Edit postfix config file

sudo vim /etc/postfix/main.cf

Set inet_interfaces to be loopback-only

inet_interfaces = loopback-only

Restart postfix

sudo service postfix restart

Git

Set name and email for commits

git config --global user.name "Your Name"
git config --global user.email YOUR@EMAIL.com

Generate an SSH keypair

ssh-keygen -t rsa -C "YOUR@EMAIL.com"

Copy the output of this command and paste into github SSH key settings.

cat ~/.ssh/id_rsa.pub

Check to make sure SSH to github works with your key

ssh -T git@github.com

PostgreSQL

Set postgres user password

sudo -u postgres createuser myuser -s

sudo -u postgres psql
postgres=# \password myuser

zsh and oh-my-zsh

sudo apt-get install zsh fonts-powerline
chsh -s $(which zsh)
# logout and back in
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

asdf version manager

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.8

add asdf plugin to ohmyzsh plugins

vim ~/.zshrc

Find the plugins line and update to this:

plugins=(git asdf)

Reload your shell

source ~/.zshrc

Double check asdf command works

asdf

Ruby and Ruby on Rails

asdf plugin-add ruby
asdf install ruby 2.7.1
asdf global ruby 2.7.1
ruby -v

Tell RubyGems to not install documentation for each gem

echo "gem: --no-ri --no-rdoc" > ~/.gemrc

Install bundler and rails

gem install bundler
gem install rails

Node.js

asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf install nodejs 12.16.2
asdf global nodejs 12.16.2
node -v

Yarn

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install --no-install-recommends yarn

Erlang, Elixir and Phoenix

Erlang

asdf plugin-add erlang
asdf install erlang 22.3.2
asdf global erlang 22.3.2

Elixir

asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
asdf install elixir 1.10.2-otp-22
asdf global elixir 1.10.2-otp-22
elixir -v

Phoenix

mix local.hex
mix archive.install hex phx_new 1.4.16

Rust

Install rust with rustup

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Other Tools

wkhtmltopdf

Download the latest ubuntu deb package

wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb

Install

sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb

Ruby rgeo library settings

Add to .zshrc

export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal

Reload shell

exec $SHELL

Make sure rgeo will be able to find geos

sudo ln -s /usr/lib/x86_64-linux-gnu/libgeos-3.8.0.so /usr/lib/libgeos.so
gem install rgeo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment