fix: detect WSL remote for shell PATH resolution
When Windows host connects to WSL remote, getEnvPathFromUserShell() was returning undefined because it checked only process.platform === "win32". Add remoteName parameter to getEnvPathFromUserShell() and use the isWindowsHostWithWslRemote pattern (consistent with resolveCommandForPlatform) to allow shell PATH detection for WSL remotes. Fixes #9737 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -563,10 +563,15 @@ Org-level secrets can only be used for MCP by Background Agents (https://docs.co
|
||||
// Set the initial PATH from process.env
|
||||
env.PATH = process.env.PATH;
|
||||
|
||||
// For non-Windows platforms, try to get the PATH from user shell
|
||||
if (process.platform !== "win32") {
|
||||
// For non-Windows platforms or WSL remotes, try to get the PATH from user shell
|
||||
const ideInfo = await this.extras?.ide?.getIdeInfo();
|
||||
const isWindowsHostWithWslRemote =
|
||||
process.platform === "win32" && ideInfo?.remoteName === "wsl";
|
||||
if (process.platform !== "win32" || isWindowsHostWithWslRemote) {
|
||||
try {
|
||||
const shellEnvPath = await getEnvPathFromUserShell();
|
||||
const shellEnvPath = await getEnvPathFromUserShell(
|
||||
ideInfo?.remoteName,
|
||||
);
|
||||
if (shellEnvPath && shellEnvPath !== process.env.PATH) {
|
||||
env.PATH = shellEnvPath;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ import { exec } from "child_process";
|
||||
import { promisify } from "util";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
export async function getEnvPathFromUserShell(): Promise<string | undefined> {
|
||||
if (process.platform === "win32") {
|
||||
console.warn(`${getEnvPathFromUserShell.name} not implemented for Windows`);
|
||||
export async function getEnvPathFromUserShell(
|
||||
remoteName?: string,
|
||||
): Promise<string | undefined> {
|
||||
const isWindowsHostWithWslRemote =
|
||||
process.platform === "win32" && remoteName === "wsl";
|
||||
if (process.platform === "win32" && !isWindowsHostWithWslRemote) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user