This is the latest version of my dev env set-up guide, perfect for use after getting a new machine or carrying out a fresh install of macOS. You can use this guide for similar web development set-ups too, since the version manager we’ll be using (asdf) is perfect for a large number of different languages.
If you don’t need Ruby or don’t need Elixir, you can just omit those steps. We’ll also add a few other common web development tools or packages. In short, we’ll be covering installation of:
- Xcode
- Command line tools
- Homebrew
- ImageMagic
- Git
- Postgres
- TextMate
- MacVim
- Asdf
- Ruby
- Rubygems
- Rails
- Erlang
- Elixir
- Hex
- Phoenix
Xcode
Simply download and install Xcode from the App store.
Command Line Tools
Once Xcode has installed, open it, then go to preferences > downloads, and install command line tools. Or alternatively, enter the following in terminal – be sure to start Xcode afterwards so you can agree to their terms:
Homebrew
In the terminal copy and paste the following:
Let’s get brewing – and install Postgres, ImageMagick and git
Let’s update Homebrew first:
Postgres
Then:
Then to start Postgres and on startup, run:
Then create your initial db:
Then:
CREATE ROLE postgres LOGIN CREATEDB;
That will create your Postgres user (use CTRL Z to exit).
Git and ImageMagick
brew install git
Then in terminal:
git config --global user.email "youremail@yourdomain.com"
Installing asdf
In terminal, type:
brew install asdf
Then add the following to your ~/.zshrc
file:
In terminal:
If you need to upgrade asdf, use brew upgrade asdf
.
How to remove asdf
If you ever need to remove asdf, you can do so pretty easily:
- In your .zshrc remove the line that was added on installation:
. . /usr/local/opt/asdf/libexec/asdf.sh
- Run
rm -rf ~/.asdf/ ~/.tool-versions
to completely remove all the asdf files from your system. - In terminal:
brew uninstall --force asdf
Installing Ruby
Skip if you don’t need Ruby and Rails…
In terminal:
To see which versions are available:
Then install the versions you want with the following, just replace 2.7.2
and 3.0.0
with which versions you need:
asdf install ruby 3.0.0
Then set your preferred defaults with:
And to use a specific version in any particular directory:
To add new Rubies:
Or simply:
Rubygems and Rails
Open a fresh terminal window and:
If you would prefer docs weren’t installed, add this to your ‘.gemrc’ file (create one if it doesn’t exist):
For Rails:
brew install yarn
Open a new terminal window and check your versions by:
rails -v
Installing Elixir & Erlang
Skip if you don’t need Elixir and Phoenix
In terminal:
asdf plugin-add Elixir
To see which versions are available:
asdf list-all elixir
Then install the versions you want with the following, just replace version numbers with whichever versions you need:
asdf global erlang 25.0.2
asdf install elixir 1.13.4-otp-25
asdf global elixir 1.13.4-otp-25
And to use a specific version in any particular directory:
Installing Hex and Phoenix
To install Phoenix:
Finally, check your versions by:
mix phx.new --version
Doesn’t that feel good? Now you can install your favourite code editors!
Code Editors
I’m going to install two here, TextMate and MacVim 😀
TextMate 2
Download from here: https://macromates.com/download
Download my Elixify theme and follow the instructions from here (but you just need to double click on the TextMate 2 theme called Elixify.tmbundle)
Install Elixir Bundle:
cd ~/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles
git clone https://github.com/elixir-editors/elixir-tmbundle.git Elixir.tmbundle
MacVim
If you want to use Janus, it can be installed by running this in terminal:
In it paste:
set guifont=Monaco:h12
let g:NERDTreeWinPos = "right"
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
autocmd User Rails let b:surround_{char2nr('-')} = "<% \r %>" " displays <% %> correctly
:set cpoptions+=$ " puts a $ marker for the end of words/lines in cw/c$ commands
Then in terminal, to give it some breathing space at the top do:
To install the Elixify theme download from here and follow the instructions for MacVim.
cd ~/.vim/colors
open .
//copy Elixify.vim there
That’s it – you now have a fully working dev environment for Ruby, Elixir, Erlang, Node and any other language you want to add via the numerous supported by asdf… which I highly recommend btw!!