How to install codex and gemini cli

ai
Author

Andrea Zonca

Published

December 2, 2025

Note

This is actually not recommended because it mixes node packages with other packages installed in .local. Recommend instead to use nvm, once configured nvm, then the standard install command works without specifying any prefix.

When installing @google/gemini-cli or @openai/codex using npm, you might encounter permission errors with the default global installation command.

The simplest way to avoid this is to install the packages in your local user directory by providing ~/.local as a prefix.

npm install --global --prefix ~/.local @google/gemini-cli
npm install --global --prefix ~/.local @openai/codex

Executable files will be placed in ~/.local/bin. This directory is typically already in your PATH.

If it’s not, you can add it to your PATH by adding the following line to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc):

export PATH=$HOME/.local/bin:$PATH

Then, reload your shell configuration (e.g., source ~/.bashrc) or open a new terminal.