Skip to content

Fix --exec using the wrong binary search path - #42194

Merged
Feng Wang (chemwolf6922) merged 1 commit into
masterfrom
user/chemwolf6922/fix-exec-using-the-wrong-binary-search-path
Nov 9, 2026
Merged

Feng Wang (chemwolf6922) merged 1 commit into
masterfrom
user/chemwolf6922/fix-exec-using-the-wrong-binary-search-path

Conversation

@chemwolf6922

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Problem: wsl --exec could fail to find commands present in the launch’s PATH because execvpe() searched init’s environment instead.

Fix: Set the final child’s environ to the prepared launch environment before execvpe(), so executable lookup uses the correct PATH.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Add test:
UnitTests::UnitTests::ExecSearchPath

@chemwolf6922
Feng Wang (chemwolf6922) requested a review from a team as a code owner November 6, 2026 06:59
Copilot AI balanced review requested due to automatic review settings November 6, 2026 06:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the change to use the prepared launch environment’s PATH for executable lookup.

No open issues 🎉

What changed in this PR

This PR fixes executable lookup for wsl --exec so commands are searched using the prepared launch environment’s PATH, rather than init’s environment.

Changes:

  • Assigns the launch environment to the final child’s environ before calling execvpe().
  • Adds an ExecSearchPath regression test that creates a command in /usr/sbin and verifies --exec finds it.
File Description
test/​windows/​wsl/​UnitTests.cpp Adds the executable search-path regression test with cleanup.
src/​linux/​init/​init.cpp Makes executable lookup use the prepared launch environment.

Review effort: Balanced

@chemwolf6922
Feng Wang (chemwolf6922) merged commit 5be2590 into master Nov 9, 2026
17 checks passed
@chemwolf6922
Feng Wang (chemwolf6922) deleted the user/chemwolf6922/fix-exec-using-the-wrong-binary-search-path branch November 9, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants