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.
Let’s say you’re playing with ImageMagick. And you’ve found all sorts of documentation that tells you what you can do with ImageMagick on Linux, but it doesn’t seem to be working on your Mac. If you’re on a Mac, you may not have some of the ImageMagick libraries by default. Brew install -v imagemagick. Not a member of Pastebin yet? Sign Up, it unlocks many cool features! Raw download clone embed print report. Mini: admin$ brew install-v imagemagick. Warning: Your Xcode (4.6.
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:
/bin/bash -c '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)'
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:
That will create your Postgres user (use CTRL Z to exit).
Git and ImageMagick
Then in terminal:
git config --global user.name 'Your Name'
git config --global user.email '[email protected]'
git config --global user.email '[email protected]'
Installing asdf
In terminal, type:
Then in terminal run:
echo -e 'n. $(brew --prefix asdf)/asdf.sh' >> ~/.zshrc
This will add the following to the bottom of 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/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: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:
Open a new terminal window and check your versions by:
Installing Elixir & Erlang
Skip if you don’t need Elixir and Phoenix
In terminal:
To see which versions are available:
Then install the versions you want with the following, just replace version numbers with whichever versions you need:
asdf install erlang 23.2.3
asdf global erlang 23.2.3
asdf install elixir 1.11.3-otp-23
asdf global elixir 1.11.3-otp-23
asdf global erlang 23.2.3
asdf install elixir 1.11.3-otp-23
asdf global elixir 1.11.3-otp-23
And to use a specific version in any particular directory:
Installing Hex and Phoenix
Phoenix uses Brunch.io which relies on npm, the Node.js package manager, so lets install that as well via asdf:
asdf plugin-add nodejs
brew install gpg
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf list-all nodejs
asdf install nodejs 15.8.0
asdf global nodejs 15.8.0
brew install gpg
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf list-all nodejs
asdf install nodejs 15.8.0
asdf global nodejs 15.8.0
To install Phoenix:
Finally, check your versions by:
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:
mkdir -p ~/Library/Application Support/TextMate/Pristine Copy/Bundles
cd ~/Library/Application Support/TextMate/Pristine Copy/Bundles
git clone git://github.com/elixir-lang/elixir-tmbundle Elixir.tmbundle
cd ~/Library/Application Support/TextMate/Pristine Copy/Bundles
git clone git://github.com/elixir-lang/elixir-tmbundle Elixir.tmbundle
MacVim
If you want to use Janus, it can be installed by running this in terminal:
In it paste:
color elixify
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
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
Homebrew Imagemagick
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.
mkdir ~/.vim/colors
cd ~/.vim/colors
open .
//copy Elixify.vim there
cd ~/.vim/colors
open .
//copy Elixify.vim there
Brew Imagemagick Rsvg
If you’re looking for even more code editors, VSCode is currently very popular but if you want to try something new, why not give Onivim a try? It wants to bring us the best of Vim and VSCode (there’s a monthly giveaway and discount on devtalk if you’re interested: onivim.devtalk.com).
Download Imagemagick
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!!