Repository navigation
For npm upgrade on Windows, go through cmd.exe to get path traversal working #6387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
iceweasel-oai
merged 4 commits into
main
from
dev/iceweasel/npm-upgrade-windows-use-cmd
Nov 10, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,10 +26,11 @@ use std::path::PathBuf; | |
| use supports_color::Stream; | ||
|
|
||
| mod mcp_cmd; | ||
| #[cfg(not(windows))] | ||
| mod wsl_paths; | ||
|
|
||
| use crate::mcp_cmd::McpCli; | ||
| use crate::wsl_paths::normalize_for_wsl; | ||
|
|
||
| use codex_core::config::Config; | ||
| use codex_core::config::ConfigOverrides; | ||
| use codex_core::features::is_known_feature_key; | ||
|
|
@@ -269,14 +270,30 @@ fn handle_app_exit(exit_info: AppExitInfo) -> anyhow::Result<()> { | |
| /// Run the update action and print the result. | ||
| fn run_update_action(action: UpdateAction) -> anyhow::Result<()> { | ||
| println!(); | ||
| let (cmd, args) = action.command_args(); | ||
| let cmd_str = action.command_str(); | ||
| println!("Updating Codex via `{cmd_str}`..."); | ||
| let command_path = normalize_for_wsl(cmd); | ||
| let normalized_args: Vec<String> = args.iter().map(normalize_for_wsl).collect(); | ||
| let status = std::process::Command::new(&command_path) | ||
| .args(&normalized_args) | ||
| .status()?; | ||
|
|
||
| let status = { | ||
| #[cfg(windows)] | ||
| { | ||
| // On Windows, run via cmd.exe so .CMD/.BAT are correctly resolved (PATHEXT semantics). | ||
| std::process::Command::new("cmd") | ||
| .args(["/C", &cmd_str]) | ||
| .status()? | ||
| } | ||
| #[cfg(not(windows))] | ||
| { | ||
| let (cmd, args) = action.command_args(); | ||
| let command_path = crate::wsl_paths::normalize_for_wsl(cmd); | ||
| let normalized_args: Vec<String> = args | ||
| .iter() | ||
| .map(crate::wsl_paths::normalize_for_wsl) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll let @dylan-hurd-oai comment on any/all WSL stuff |
||
| .collect(); | ||
| std::process::Command::new(&command_path) | ||
| .args(&normalized_args) | ||
| .status()? | ||
| } | ||
| }; | ||
| if !status.success() { | ||
| anyhow::bail!("`{cmd_str}` failed with status {status}"); | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)...