Skip to content

Commit 247736b

Browse files
committed
improve error message when spawning language server fails with more context
1 parent dc96d7e commit 247736b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/instance.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::hash_map::Entry;
22
use std::collections::{BTreeMap, HashMap, HashSet};
3+
use std::env;
34
use std::io::ErrorKind;
45
use std::ops::Deref;
56
use std::path::Path;
@@ -431,9 +432,22 @@ async fn spawn(
431432
.stderr(Stdio::piped())
432433
.spawn()
433434
.with_context(|| {
435+
let InstanceKey {
436+
server,
437+
args,
438+
env,
439+
workspace_root,
440+
} = &key;
441+
let path = env
442+
.get("PATH")
443+
.map(<_>::to_owned)
444+
// Display PATH from our environment Command will if none was
445+
// passed from the client environment.
446+
.or_else(|| env::var("PATH").ok())
447+
.unwrap_or_default();
434448
format!(
435-
"spawning langauge server: server={:?}, args={:?}, cwd={:?}",
436-
key.server, key.args, key.workspace_root,
449+
"spawning langauge server: server={server:?}, args={args:?}, \
450+
cwd={workspace_root:?}, path={path:?}, env={env:?}",
437451
)
438452
})?;
439453

0 commit comments

Comments
 (0)