How to install codex and gemini cli

Author

Andrea Zonca

Published

December 2, 2025

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.