Skip to content

For npm upgrade on Windows, go through cmd.exe to get path traversal working - #6387

Merged
iceweasel-oai merged 4 commits into
mainfrom
dev/iceweasel/npm-upgrade-windows-use-cmd
Nov 10, 2025
Merged

iceweasel-oai merged 4 commits into
mainfrom
dev/iceweasel/npm-upgrade-windows-use-cmd

Conversation

@iceweasel-oai

Copy link
Copy Markdown
Contributor

On Windows, npm by itself does not resolve under std::process::Command which does not consider PATHEXT to resolve it to npm.cmd in the PATH.
By running the npm upgrade command via cmd.exe we get proper path semantics so it actually works.

Comment thread codex-rs/cli/src/main.rs Outdated
@bolinfest
bolinfest self-requested a review November 10, 2025 00:05
Comment thread codex-rs/cli/src/main.rs Outdated
let normalized_args: Vec<String> = args.iter().map(normalize_for_wsl).collect();
// On Windows, run via cmd.exe so .CMD/.BAT are correctly resolved (PATHEXT semantics).
#[cfg(windows)]
let status = std::process::Command::new("cmd")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd.exe for good measure?

Comment thread codex-rs/cli/src/main.rs
use supports_color::Stream;

mod mcp_cmd;
#[cfg(not(windows))]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit surprising that WSL is needed when not(windows)...

Comment thread codex-rs/cli/src/main.rs
let command_path = crate::wsl_paths::normalize_for_wsl(cmd);
let normalized_args: Vec<String> = args
.iter()
.map(crate::wsl_paths::normalize_for_wsl)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit wrong as none of the update args should be paths, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let @dylan-hurd-oai comment on any/all WSL stuff

@iceweasel-oai
iceweasel-oai merged commit 625f220 into main Nov 10, 2025
25 checks passed
@iceweasel-oai
iceweasel-oai deleted the dev/iceweasel/npm-upgrade-windows-use-cmd branch November 10, 2025 05:07
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants