diff --git a/CHANGELOG.md b/CHANGELOG.md index 01ca554f..bfe1506c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,18 @@ and listed with their assets on the ## [Unreleased] +### Fixed + +- **Sharing on Windows finds devstack installed as the setup says.** The + hub ran its scripts in the WSL distribution with `wsl.exe … -- sh -c`, + which hands them to the distribution's shell first: that shell expanded + them before `sh` ran, so the setup's check looked for devstack without + `~/.local/bin`, where `install.sh` puts it, and said "devstack is not + installed in the distribution" right after the install. The hub runs + them with `--exec` now, as written (#597). Until this release, a link + helps: `ln -sf /root/.local/bin/devstack /usr/local/bin/devstack` in the + distribution as root. + ## [0.51.0] - 2026-11-19 Sharing a machine starts with a setup dialog: it says what sharing does, diff --git a/crates/devstack-hub/src/nodehost.rs b/crates/devstack-hub/src/nodehost.rs index 0679fa36..3932dd84 100644 --- a/crates/devstack-hub/src/nodehost.rs +++ b/crates/devstack-hub/src/nodehost.rs @@ -968,10 +968,12 @@ pub mod wsl { } /// `script` in `distro` as root, with `~/.local/bin` (where - /// `install.sh` puts devstack) and WSL's GPU tools on `PATH`. - fn sh(distro: &str, script: &str) -> Command { + /// `install.sh` puts devstack) and WSL's GPU tools on `PATH`. With + /// `--exec`, not `--`: that hands the command to the distribution's + /// shell first, which expands the script before `sh` sees it (#597). + pub fn sh(distro: &str, script: &str) -> Command { let mut c = command(); - c.args(["-d", distro, "-u", "root", "--", "sh", "-c"]); + c.args(["-d", distro, "-u", "root", "--exec", "sh", "-c"]); c.arg(format!( "PATH=\"$HOME/.local/bin:/usr/local/bin:/usr/lib/wsl/lib:$PATH\"; export PATH; {script}" )); @@ -1397,6 +1399,28 @@ mod tests { assert_eq!(guests_or(None, None), None); } + /// #597: `wsl.exe … -- cmd` hands `cmd` to the distribution's default + /// shell first, which expands `$HOME`, `$PATH` and every `$(…)` of the + /// script before `sh` runs it: the probe then looked for devstack on + /// the default `PATH`, without `~/.local/bin`. `--exec` runs `sh` with + /// the script as one argument, as written. + #[test] + fn a_script_reaches_sh_in_the_distribution_as_written() { + let script = "echo \"devstack=$(devstack --version)\""; + let c = wsl::sh("Ubuntu-24.04", script); + let args: Vec = c + .get_args() + .map(|a| a.to_string_lossy().into_owned()) + .collect(); + let exec = args.iter().position(|a| a == "--exec"); + assert!(exec.is_some(), "{args:?}"); + assert!(!args.iter().any(|a| a == "--"), "{args:?}"); + let rest = &args[exec.unwrap() + 1..]; + assert_eq!(rest[..2], ["sh", "-c"], "{args:?}"); + assert_eq!(rest.len(), 3, "the script is one argument: {args:?}"); + assert!(rest[2].ends_with(script) && rest[2].contains("$HOME/.local/bin")); + } + #[test] fn words_for_sh_and_lines_of_wsl_exe() { assert_eq!(wsl::quote("a b"), "'a b'"); diff --git a/docs/pool.md b/docs/pool.md index a65e5927..840d5dcc 100644 --- a/docs/pool.md +++ b/docs/pool.md @@ -106,8 +106,9 @@ did; their owners stop them, or an admin ends the lease. `networkingMode=mirrored` in `.wslconfig`, and devstack of the same version installed as root. The hub copies the machine's membership into it (`/var/lib/devstack-node/`, root only: one member per machine) - and runs `wsl.exe -d -u root -- devstack node agent --membership - …`. It never sets the distribution up: it checks it (the networking mode, + and runs `wsl.exe -d -u root --exec sh -c 'exec devstack node agent + --membership …'` (with `~/.local/bin`, where `install.sh` puts devstack, on + `PATH`). It never sets the distribution up: it checks it (the networking mode, the engine, devstack's version, an NVIDIA GPU and the container toolkit, the Hyper-V firewall rule `devstack-node` for the port) and shows what is missing with the command for it, and a prompt a coding agent can work