- 21 May 2024
- 2 Minutes to read
- Print
- DarkLight
- PDF
Setup for macOS
- Updated on 21 May 2024
- 2 Minutes to read
- Print
- DarkLight
- PDF
Git setup
Depending on the operating system, Git may already be installed.
To determine if it is installed, run: git --version
If the response is a git version, then it is already installed.
If it is not installed, follow the steps below to install it.
If git is not installed, macOS should prompt you to install it when the version
command was unsuccessful.
Python and Node
This setup also helps you achieve deterministic builds and an overall more consistent work environment. You won’t have to manually manage the Python virtualenv
locations and names anymore. For Node, global packages are installed based on the version.
The setup makes use of pyenv and nvm, which are version managers for Python and Node respectively. You can think of these tools as scripts that dynamically modify your path
environment variable as you switch versions, ensuring that version locations and directories are cleanly separated and that the right version is called when you run python
or node
in a given directory.
Note: This process refers to python
and python3
. Before attempting these steps, determine which of these your environment uses and then follow the corresponding instructions.
Python
Complete the following steps to set up your environment for Python.
Install pyenv.
Install Homebrew
/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)"
Install pyenv using Homebrew.
brew update
brew install pyenv
Add pyenv to your PATH.
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc echo 'eval "$(pyenv init -)"' >> ~/.zshrc
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc
Restart your shell for changes to take effect.
exec "$SHELL"
Set up your build environment for Python.
If you haven't installed the XCode CLI yet, install it now.
xcode-select --install
Install the Python build dependencies using Homebrew.
brew install openssl readline sqlite3 xz zlib tcl-tk
Install a python version and set it as the global default:
pyenv install <version> pyenv rehash pyenv global <version>
replacing
<version>
with the latest version.Install Python tools.
Node
Complete the following steps to set up your environment for Node and nvm.
Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Restart your shell for changes to take effect.
exec "$SHELL"
Install a node version and set it as the global default.
nvm install 18.16.0
nvm alias default 18.16.0
Add deeper shell integration using the instructions in GitHub's nvm Deeper Shell Integration documentation. With this functionality, when you change directories the node version switches automatically to match the new directory.
Enable Node Corepack so you can use the latest version of Yarn.
corepack enable
PostgreSQL for macOS
Add ~/.local/bin
and the PostgreSQL bin directory to your PATH
variable in the ~/.zshrc
file:
export PATH=$HOME/.local/bin:$PATH
export PATH=/library/postgresql/15/bin:$PATH
Yarn setup
Depending on the operating system, Yarn may already be installed.
To determine if it is installed, run: yarn --version
If the response is a version, then it is already installed.
If it is missing, ensure you have installed Node.
If Node is installed, and Yarn is not, install it by running:
npm install --global yarn
For more detailed instructions on installing Yarn, refer to the Yarn documentation.