Setting up Codex in Jupyterhub with university HPC service
The Jupyterhub is a possibility to work interactively with the cluster and workstations provided by the Faculty of Physics at LMU. The only client required is a web browser. On login, you can specify the resources you need and the environment you would like to use. All environments include the Jupyterlab interface and a set of notebook types for different programming languages. In addition to the notebooks, a fully functional Linux terminal is also available. Please see here for information (Note that a valid uni account is needed to access the docs).
After you successfully login in to Jupyterhub session, open a terminal and use the following command:
module avail nodeafter which you should see available version of Node.js, eg. node/24.12.0, which is needed for installing Codex CLI. Load the module with:
module load node/24.12.0To check if you have no problems until here, run:
node -v
npm -vwhich shoud output the versions of node and npm.
Run the following in your home directory(which should be default after you login in) to install Codex CLI:
npm install -g @openai/codexIf you have authorization problems, try:
npm config set prefix ~/.npm-global
export NPM_CONFIG_PREFIX=$HOME/.npm-global
export PATH=$HOME/.npm-global/bin:$PATHwhich adds the executable to your PATH environment variable temporarily.
After you successfully install the Codex CLI, run:
codex loginThen you could interact with Codex easily with command lines.
Alternatively, you could write a script(with a name codex-env.sh as an example):
#!/bin/bash
module load node/24.12.0
export NPM_CONFIG_PREFIX=$HOME/.local
export PATH=$HOME/.local/bin:$PATH
if ! command -v codex &> /dev/null
then
echo "Installing Codex CLI..."
npm install -g @openai/codex
fi
codexand everytime you want to use Codex, just run the script with the command:
source ~/codex-env.shYou could also use VS Code editor remotely(in the JupyterHub session) or locally if you prefer it and install the codex extension, which enables a chatbox alongside your code.