- 21 May 2024
- 2 Minutes to read
- Print
- DarkLight
- PDF
Setup for Linux
- 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.
Run the following command: sudo apt install git-all
For more detailed instructions on installing Git, refer to the Git documentation.
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:
curl https://pyenv.run | bash
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:
For Ubuntu or Debian
sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev \\ libbz2-dev libreadline-dev libsqlite3-dev curl \\ libncursesw5-dev xz-utils tk-dev libxml2-dev \\ libxmlsec1-dev libffi-dev liblzma-dev
For other Linux distros, refer to the instructions in the Suggested build environment documentation in the pyenv GitHub.
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
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.