diff --git a/apps/desktop/src/backend/DesktopBackendConfiguration.ts b/apps/desktop/src/backend/DesktopBackendConfiguration.ts index a190b8f62e..a99420e407 100644 --- a/apps/desktop/src/backend/DesktopBackendConfiguration.ts +++ b/apps/desktop/src/backend/DesktopBackendConfiguration.ts @@ -154,8 +154,8 @@ interface SharedBootstrapInput { interface WslPreflightOutcome { readonly _tag: "Ready"; readonly linuxEntryPath: string; - // Absolute path to the node binary the preflight validated (after sourcing - // the user's version managers). The launch must use this exact path so it + // Absolute path to the node binary the preflight validated after the shared + // remote resolver repaired PATH. The launch must use this exact path so it // doesn't fall through to a different/old node than the one node-pty was // built against. readonly nodePath: string; @@ -448,10 +448,10 @@ const resolveWslStartConfig = Effect.fn("desktop.backendConfiguration.resolveWsl args: [ ...distroArgs, "--", - // Absolute node path resolved by the preflight (sourcing nvm/fnm/asdf/ - // volta). `wsl.exe -- node` would run against the bare non-login PATH and - // hit /usr/bin/node instead of the version-managed node node-pty was - // built against. + // Absolute node path resolved by the preflight after the shared remote + // resolver repaired PATH. `wsl.exe -- node` would run against the bare + // non-login PATH and hit /usr/bin/node instead of the version-managed + // node node-pty was built against. preflight.nodePath, preflight.linuxEntryPath, "--bootstrap-fd", diff --git a/apps/desktop/src/wsl/DesktopWslEnvironment.ts b/apps/desktop/src/wsl/DesktopWslEnvironment.ts index a5bb15f4b4..9659178e1a 100644 --- a/apps/desktop/src/wsl/DesktopWslEnvironment.ts +++ b/apps/desktop/src/wsl/DesktopWslEnvironment.ts @@ -8,6 +8,7 @@ import * as Path from "effect/Path"; import * as Stream from "effect/Stream"; import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"; +import { buildRemoteNodeEnvScript } from "@t3tools/ssh/tunnel"; import { satisfiesSemverRange } from "@t3tools/shared/semver"; import * as DesktopEnvironment from "../app/DesktopEnvironment.ts"; @@ -86,23 +87,12 @@ interface ShellResult { const TIMEOUT_RESULT: ShellResult = { exitCode: 124, stdout: "", stderr: "\n[timeout]" }; -// nvm / fnm / asdf / volta install their shell hooks at the BOTTOM of -// ~/.bashrc, below the `case $- in *i*) ;; *) return` interactive guard, so a -// non-interactive `bash -l` returns before reaching them and `node` falls -// through to the system /usr/bin/node (often an old apt build) or nothing. -// Source the common managers explicitly — all output suppressed so it can't -// pollute the parsed stdout — so the toolchain check, the node-pty -// probe/build, and the resolved launch path all agree on the user's real node. -const NODE_MANAGER_PREAMBLE = [ - 'export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"', - '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" >/dev/null 2>&1', - 'command -v nvm >/dev/null 2>&1 && ! command -v node >/dev/null 2>&1 && nvm use default >/dev/null 2>&1', - '[ -s "$HOME/.asdf/asdf.sh" ] && . "$HOME/.asdf/asdf.sh" >/dev/null 2>&1', - '[ -d "$HOME/.volta/bin" ] && PATH="$HOME/.volta/bin:$PATH"', - 'for __t3d in "$HOME/.local/share/fnm" "$HOME/.fnm"; do [ -d "$__t3d" ] && PATH="$__t3d:$PATH"; done; unset __t3d', - 'command -v fnm >/dev/null 2>&1 && eval "$(fnm env 2>/dev/null)" >/dev/null 2>&1', - "", -].join("\n"); +// Reuse the SSH remote resolver so WSL and SSH discover version-managed Node +// the same way. WSL keeps its separate toolchain version check, so this script +// is built without an engine range and used only to repair PATH. +const WSL_NODE_ENV_PREAMBLE = `${buildRemoteNodeEnvScript()} +ensure_remote_node_path || true +`; // wsl.exe re-escapes args before forwarding them to the Linux side, which // mangles quotes inside `bash -lc "