This README explains how to install a global Codex CLI/SDK and fetch its configuration from the cfgmgr/codex GitHub repository using curl. All global installs/updates use the explicit path /usr/bin/npm i -g -U as requested.
Note: This guide assumes your package is named
openai-codexand that a config file exists incfgmgr/codex. If your package name or config path differs, adjust the commands accordingly.
- Quick Start
- Prerequisites
- Install
- Configuration
- Environment Variables
- Usage
- Update
- Troubleshooting
- Uninstall
- Security Notes
- FAQ
- Support
- License
- Summary
# 1) Verify prerequisites
node -v
curl --version
# 2) Install/upgrade globally (uses the full npm path)
sudo /usr/bin/npm i -g -U openai-codex
# 3) Create a config directory
mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/codex"
# 4) Pull config from GitHub (adjust file path if needed)
CONFIG_URL="https://raw.githubusercontent.com/cfgmgr/codex/main/codex.config.json"
curl -fsSL "$CONFIG_URL" -o "${XDG_CONFIG_HOME:-$HOME/.config}/codex/config.json"
# 5) Set your API key (if applicable)
export OPENAI_API_KEY="sk-...your-key..."
# 6) Verify installation (replace 'codex' with your CLI name if different)
codex --version || codex --help- Node.js: Version 18+ recommended.
- npm: Comes with Node.js. This guide uses
/usr/bin/npmexplicitly. - curl: Required for fetching configuration from GitHub.
- A Unix-like shell (macOS/Linux). Windows users can use WSL or PowerShell and adapt paths.
Install Node quickly:
- macOS:
brew install node - Ubuntu/Debian:
sudo apt-get update && sudo apt-get install -y nodejs npm
For newer Node versions, consider NodeSource, Volta, or nvm.
- Confirm where
npmlives:
which npm
ls -l /usr/bin/npm || echo "/usr/bin/npm not found; adjust commands accordingly"- Install or upgrade the global package:
# Exact path and flags as requested
sudo /usr/bin/npm i -g -U openai-codex- Confirm the CLI/library is available:
which codex || echo "If no 'codex' on PATH, check your package's binary name or global npm bin path."
codex --help || trueIf your package exposes a different CLI name, substitute it for
codexin the examples.
This guide stores configuration under ~/.config/codex (or $XDG_CONFIG_HOME/codex if set). It pulls a JSON config file from the cfgmgr/codex repository using GitHub’s raw content endpoint.
- Create the config directory:
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/codex"
mkdir -p "$CONFIG_DIR"- Choose the raw config URL. Update the branch/path/file as needed:
CONFIG_URL="https://raw.githubusercontent.com/cfgmgr/codex/main/codex.config.json"- Download the config:
curl -fsSL "$CONFIG_URL" -o "$CONFIG_DIR/config.json"
echo "Wrote config to: $CONFIG_DIR/config.json"- Sanity-check the config content:
head -n 20 "$CONFIG_DIR/config.json" || true
# If you have jq installed:
# jq . "$CONFIG_DIR/config.json"- Alternative formats/paths (examples; adjust as needed):
https://raw.githubusercontent.com/cfgmgr/codex/main/config/codex.yamlhttps://raw.githubusercontent.com/cfgmgr/codex/master/conf/codex.toml
If you use YAML/TOML, update the filename and the tool’s config path accordingly.
Most code-generation tools require an API key.
- Set your OpenAI API key:
export OPENAI_API_KEY="sk-...your-key..."- Optional variables (adjust per your tool’s docs):
CODEX_CONFIG_PATH: Absolute path to a specific config fileHTTP_PROXY/HTTPS_PROXY: Proxy support if requiredNO_PROXY: Comma-separated list of hosts not to proxyDEBUG=1: Enable verbose logging if supported
Persist environment variables by adding them to your shell profile (e.g., ~/.bashrc, ~/.zshrc).
- CLI usage (if the package exposes
codex):
codex --help
codex run --config "${XDG_CONFIG_HOME:-$HOME/.config}/codex/config.json"- Programmatic usage example:
mkdir codex-demo && cd codex-demo
npm init -y
/usr/bin/npm i -U openai-codex
# Example Node script (adjust import per the actual SDK)
cat > demo.js <<'JS'
async function main() {
console.log("Codex demo starting...");
// const { Codex } = require('openai-codex'); // or ESM import
// const client = new Codex({ apiKey: process.env.OPENAI_API_KEY });
// const result = await client.generate({ prompt: "Hello, world!" });
// console.log(result);
console.log("Codex demo OK (placeholder).");
}
main().catch(err => { console.error(err); process.exit(1); });
JS
node demo.jsReplace imports and example calls with the API actually provided by your package.
- Upgrade the global package to the latest version:
sudo /usr/bin/npm i -g -U openai-codex- Refresh your configuration from GitHub:
CONFIG_URL="https://raw.githubusercontent.com/cfgmgr/codex/main/codex.config.json"
curl -fsSL "$CONFIG_URL" -o "${XDG_CONFIG_HOME:-$HOME/.config}/codex/config.json"- “/usr/bin/npm: No such file or directory”
- Your system’s
npmmay be elsewhere (e.g.,/usr/local/bin/npm). Runwhich npmand either adjust the path or create a symlink.
- Your system’s
- “Permission denied” during global install
- Use
sudo, or configure a user-level global prefix:
npm config set prefix "$HOME/.npm-global"and add$HOME/.npm-global/binto your PATH.
- Use
- CLI not found after install
- Ensure the package exposes a binary and your global npm bin dir is on
PATH. Checknpm bin -g.
- Ensure the package exposes a binary and your global npm bin dir is on
- 404 or error when fetching config
- Verify repo, branch (e.g.,
mainvsmaster), file path, and that your network/proxy allows GitHub access.
- Verify repo, branch (e.g.,
- Proxy issues
- Set
HTTP_PROXY,HTTPS_PROXY, and possiblyNO_PROXY. Test withcurl -v.
- Set
- Config format mismatch
- Confirm your tool expects JSON vs YAML/TOML and point
--configor env vars to the correct file.
- Confirm your tool expects JSON vs YAML/TOML and point
sudo /usr/bin/npm uninstall -g openai-codex
rm -f "${XDG_CONFIG_HOME:-$HOME/.config}/codex/config.json"
rmdir "${XDG_CONFIG_HOME:-$HOME/.config}/codex" 2>/dev/null || true- Never commit secrets (like
OPENAI_API_KEY) to version control. - Restrict permissions on your config directory if it contains sensitive values:
chmod 700 "${XDG_CONFIG_HOME:-$HOME/.config}/codex"
chmod 600 "${XDG_CONFIG_HOME:-$HOME/.config}/codex/config.json"- Consider using a secrets manager or environment variable injection for CI/CD.
-
“Is ‘OpenAI Codex’ deprecated?”
The original Codex models are sunset. This README assumes you’re installing an npm package namedopenai-codex(or similar) that provides code-generation functionality. If your package uses different model names or APIs, follow its documentation. -
“Can I use a different config location?”
Yes. Either setCODEX_CONFIG_PATH(if supported) or pass a--configflag to the CLI if it provides one. -
“How do I keep global installs reproducible?”
Pin a version:sudo /usr/bin/npm i -g -U openai-codex@X.Y.Z.
- Issues with the npm package: open an issue in the package’s repository.
- Problems with configuration retrieval: verify the file path and branch in
cfgmgr/codex, then open an issue there if needed.
Include your project’s license information here (e.g., MIT). If you’re consuming third-party packages, follow their licenses accordingly.
- Installed the global package using
sudo /usr/bin/npm i -g -U openai-codex. - Fetched configuration from
cfgmgr/codexwithcurland stored it under~/.config/codex/config.json. - Set environment variables, verified the CLI/library, and provided steps to update, troubleshoot, and uninstall.