Setting Up macOS for Web Development
Getting your development environment running and configured has become much easier over time but it’s still a hassle to get everything set up and configured from scratch. These notes are a continuously evolving task list for my personal setup.
- Install Docker desktop, configure it as needed and remember to authenticate it.
- Install VS Code and log in to synchronize settings. Then some authentication:
- For GitLab, pull from any GL repo and then enter username + personal access token
- Install iTerm2.
- Install Homebrew and following packages
- Install Powerline fonts (clone, run install script)
- Install Oh my zsh
- To get
ssh-agentstarting up automatically you need to run
sudo touch /var/db/useLSand then reboot.
- Generating a secure SSH key:
ssh-keygen -t ed25519 -a 100
git config --global user.email "firstname.lastname@example.org" git config --global user.name "Your Name" git config --global init.defaultBranch main
Node is almost as bad as Python with different versions so using
nvm is a must. After installing it with brew, install few of the necessary versions and then set the default:
nvm install 12 nvm install 14 nvm install 16 nvm alias default 16
Now the default version does not use the latest node but the latest 16.x instead. Whenever a project needs different version, just say
nvm use x to activate the needed version.
To minimize XKCD 1987 the best way to handle Python versions is to only use pyenv. So
brew install pyenv (and
brew install pyenv-virtualenv). Then, importantly, add both of these lines to make sure pyenv is loaded for new terminal sessions automatically:
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile echo 'eval "$(pyenv init -)"' >> ~/.zshrc echo 'eval "$(virtualenv-init init -)"' >> ~/.zshrc
Now just install the latest usable (ie. not the point zero version of a new release) Python version and set it as global default.
Poetry is easiest to install with the installation script.
Postgis / GDAL / GEOS
Previously I haven’t had much problem with these as they install easily with Homebrew, but on macOS Monterey and Apple Silicon (M1) I had to add these to Django settings to get them working:
GDAL_LIBRARY_PATH = '/opt/homebrew/opt/gdal/lib/libgdal.dylib' GEOS_LIBRARY_PATH = '/opt/homebrew/opt/geos/lib/libgeos_c.dylib'