From 4a38e74c773ddea96f6804939fd33deb856609bd Mon Sep 17 00:00:00 2001 From: David Wiesen Date: Tue, 23 Jun 2026 09:39:55 -0700 Subject: [PATCH] windows-sandbox: stop forcing npm offline mode --- codex-rs/windows-sandbox-rs/src/env.rs | 31 +++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/codex-rs/windows-sandbox-rs/src/env.rs b/codex-rs/windows-sandbox-rs/src/env.rs index bdf7a76ab2..9e96a9467b 100644 --- a/codex-rs/windows-sandbox-rs/src/env.rs +++ b/codex-rs/windows-sandbox-rs/src/env.rs @@ -143,9 +143,6 @@ pub fn apply_no_network_to_env(env_map: &mut HashMap) -> Result< env_map .entry("PIP_DISABLE_PIP_VERSION_CHECK".into()) .or_insert_with(|| "1".into()); - env_map - .entry("NPM_CONFIG_OFFLINE".into()) - .or_insert_with(|| "true".into()); env_map .entry("CARGO_NET_OFFLINE".into()) .or_insert_with(|| "true".into()); @@ -175,3 +172,31 @@ pub fn apply_no_network_to_env(env_map: &mut HashMap) -> Result< reorder_pathext_for_stubs(env_map); Ok(()) } + +#[cfg(test)] +mod tests { + use super::apply_no_network_to_env; + use std::collections::HashMap; + + #[test] + fn no_network_env_keeps_general_guards_without_forcing_npm_offline() { + let mut env_map = HashMap::new(); + + apply_no_network_to_env(&mut env_map).expect("apply no-network env"); + + assert_eq!(env_map.get("SBX_NONET_ACTIVE").map(String::as_str), Some("1")); + assert_eq!( + env_map.get("HTTP_PROXY").map(String::as_str), + Some("http://127.0.0.1:9") + ); + assert_eq!(env_map.get("PIP_NO_INDEX").map(String::as_str), Some("1")); + assert_eq!( + env_map.get("CARGO_NET_OFFLINE").map(String::as_str), + Some("true") + ); + assert!( + !env_map.contains_key("NPM_CONFIG_OFFLINE"), + "npm should fail through the generic network denial path instead of package-manager offline mode" + ); + } +}