Last active
September 26, 2025 20:24
-
-
Save TonyGravagno/79e703f724808764170bf9d5a4d6dfce to your computer and use it in GitHub Desktop.
Suppress annoying NPM warning in ChatGPT Codex Web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Setup script for Codex Web for NPM project | |
| # Tony Gravagno : 2025/09/23 | |
| # https://gist.github.com/TonyGravagno/79e703f724808764170bf9d5a4d6dfce | |
| # To use in Codex Web, set these lines at the top of your Setup Script : | |
| # chmod +x codex_setup_for_npm_http-proxy.sh | |
| # source ./codex_setup_for_npm_http-proxy.sh | |
| # The entire purpose of this script is to suppress the annoying NPM warning: | |
| # > npm warn Unknown env config "http-proxy". This will stop working in the next major version of npm. | |
| # This will probably be obsolete soon. Please check the gist for confirmation about the | |
| # version of Codex and npm where this no longer has value. | |
| # Flow: | |
| # 1. Check to see if xtrace is set so that it toggles back on the way out. | |
| # 2. Disable xtrace (output of commands before execution). | |
| # 3. Upgrade npm to latest version | |
| # 4. Remove whatever might be causing warning. | |
| # 5. Set the proxy correctly for this environment: | |
| LOCAL_PROXY="http://proxy:8080" | |
| # 6. npm install for packages, warning should no longer display in this session | |
| ########## | |
| # We could easily 'set +x' ... do stuff ... 'set -x', but this is more elegant: | |
| # Capture whether xtrace (-x) is currently enabled, then turn it off | |
| case "$-" in | |
| *x*) HAD_XTRACE=1; set +x ;; # xtrace was on → remember & disable | |
| *) HAD_XTRACE=0 ;; # xtrace was off | |
| esac | |
| # Exit correctly : Choose a trap that works for executed vs sourced | |
| if (return 0 2>/dev/null); then | |
| # Script is being *sourced* : restore on RETURN (fires when sourcing ends) | |
| trap '[[ $HAD_XTRACE == 1 ]] && set -x' RETURN | |
| else | |
| # Script is being *executed* : restore on EXIT (fires when process ends) | |
| trap '[[ $HAD_XTRACE == 1 ]] && set -x' EXIT | |
| fi | |
| ########## | |
| # Ensure complete failure if anything fails | |
| set -euo pipefail | |
| echo "=== Upgrade NPM ===" | |
| # Remove loglevel option to see the http-proxy warning | |
| echo "Version was $(npm --loglevel=error -v)" | |
| npm --no-progress install --loglevel=error -g npm@latest | |
| echo "Version is now $(npm --loglevel=error -v)" | |
| echo "=== Unset proxy env vars only in this shell ===" | |
| # Unset all common variants so subsequent npm runs in this shell won't see them | |
| unset NPM_CONFIG_PROXY || true | |
| unset NPM_CONFIG_HTTPS_PROXY || true | |
| unset NPM_CONFIG_HTTP_PROXY || true | |
| unset npm_config_proxy || true | |
| unset npm_config_https_proxy || true | |
| unset npm_config_http_proxy || true | |
| unset HTTP_PROXY || true | |
| unset HTTPS_PROXY || true | |
| unset NO_PROXY || true | |
| unset http_proxy || true | |
| unset https_proxy || true | |
| unset no_proxy || true | |
| echo "=== Remove proxy keys from npmrc files ===" | |
| # This persists outside of the current shell for the entire session | |
| npm --no-progress config delete proxy || true | |
| npm --no-progress config delete https-proxy || true | |
| npm --no-progress config delete noproxy || true | |
| npm --no-progress config delete http-proxy || true | |
| # Scrub proxy lines directly (just in case) | |
| echo "=== Scrubbing npm config files for proxy lines ===" | |
| USER_NPMRC="$(npm config get userconfig)" | |
| GLOBAL_NPMRC="$(npm config get globalconfig)" | |
| for F in "$USER_NPMRC" "$GLOBAL_NPMRC"; do | |
| if [ -f "$F" ]; then | |
| sed -i.bak '/^\s*proxy\s*=/Id; /^\s*https-proxy\s*=/Id; /^\s*http-proxy\s*=/Id; /^\s*noproxy\s*=/Id' "$F" | |
| fi | |
| done | |
| echo "=== Verify (no warnings expected) ===" | |
| npm --no-progress config get proxy || true | |
| npm --no-progress config get https-proxy || true | |
| npm --no-progress config get noproxy || true | |
| npm --no-progress config get http-proxy || true | |
| echo "=== Re-introduce valid settings ===" | |
| npm --no-progress config set proxy $LOCAL_PROXY | |
| npm --no-progress config set https-proxy $LOCAL_PROXY | |
| echo "=== npm install for app/package ===" | |
| npm --no-progress install | |
| echo "=== Completed Codex setup for npm http-proxy ===" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While this works during setup, the warning comes back later. It seems Codex resets its proxies after setup?
So for now this gist is not actually as effective as I had thought/hoped. 😢 Sorry.
Look forward to a change in Codex : openai/codex#4193 (Web and maybe CLI)
I'll update gist if I can figure out how to keep the http-proxy from changing after it's set here.
FOSS contributions are welcome. 😉