From 247736b359fc46c19b0f7fef19504861c4b38332 Mon Sep 17 00:00:00 2001 From: max Date: Mon, 29 Jul 2024 11:52:49 +0200 Subject: [PATCH] improve error message when spawning language server fails with more context --- src/instance.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/instance.rs b/src/instance.rs index e586fbd..c358308 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -1,5 +1,6 @@ use std::collections::hash_map::Entry; use std::collections::{BTreeMap, HashMap, HashSet}; +use std::env; use std::io::ErrorKind; use std::ops::Deref; use std::path::Path; @@ -431,9 +432,22 @@ async fn spawn( .stderr(Stdio::piped()) .spawn() .with_context(|| { + let InstanceKey { + server, + args, + env, + workspace_root, + } = &key; + let path = env + .get("PATH") + .map(<_>::to_owned) + // Display PATH from our environment Command will if none was + // passed from the client environment. + .or_else(|| env::var("PATH").ok()) + .unwrap_or_default(); format!( - "spawning langauge server: server={:?}, args={:?}, cwd={:?}", - key.server, key.args, key.workspace_root, + "spawning langauge server: server={server:?}, args={args:?}, \ + cwd={workspace_root:?}, path={path:?}, env={env:?}", ) })?;