//! WSL transport of remote development: `openidea-server --stdio` started with //! `wsl.exe --exec` inside a distro, instead of over SSH. //! //! Every command goes through `--exec`, which runs the program directly without a shell on //! the Windows side; only fixed scripts reach `sh -c` inside the distro and everything variable //! (paths, versions) is passed as positional arguments, never spliced into the script. use crate::remote_dev::{PROBE_MARK, Progress, RemoteStage, SERVER_BIN, SERVER_DIR}; use ide_core::{IdeError, IdeResult}; use ide_jsonrpc::{Handler, Peer}; use parking_lot::Mutex; use std::collections::VecDeque; use std::process::Stdio; use std::sync::Arc; use std::time::Duration; use tokio::io::AsyncWriteExt; /// Bound for the short probes; `wsl.exe` can wait on a distro that is still starting. const PROBE_TIMEOUT: Duration = Duration::from_secs(60); const INSTALL_TIMEOUT: Duration = Duration::from_secs(300); const UPLOAD_CHUNK: usize = 256 * 1024; /// Output lines of the server kept for the error shown when it dies early. const KEPT_LINES: usize = 20; /// What the probe learned about a distro. #[derive(Debug, PartialEq, Eq)] pub(crate) struct Probe { pub home: String, /// `uname -sm`. pub uname: String, /// Installed builds of this version (paths of `openidea-server`). pub installed: Vec, } fn checked(distro: &str) -> IdeResult<&str> { if ide_core::wsl::is_valid_distro(distro) { Ok(distro) } else { Err(IdeError::invalid(format!("'{distro}' is not a valid WSL distribution name"))) } } /// `wsl.exe -d --exec sh -c