Environment loading fixes (#19144)
Closes #19040 Addresses the problem with annoying error messages on windows (see comment from SomeoneToIgnore on #18567) Release Notes: - Fixed the bug where language servers from PATH would sometimes be prioritised over the ones from `direnv` - Stopped running environment loading on windows as it didn't work anyways due to `SHELL` not being set
This commit is contained in:
parent
a77ec94cbc
commit
128619899e
2 changed files with 35 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::environment::EnvironmentErrorMessage;
|
||||
use std::process::ExitStatus;
|
||||
|
||||
#[cfg(not(any(test, feature = "test-support")))]
|
||||
#[cfg(not(any(target_os = "windows", test, feature = "test-support")))]
|
||||
use {collections::HashMap, std::path::Path, util::ResultExt};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -30,14 +30,18 @@ impl From<DirenvError> for Option<EnvironmentErrorMessage> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(test, feature = "test-support")))]
|
||||
pub async fn load_direnv_environment(dir: &Path) -> Result<HashMap<String, String>, DirenvError> {
|
||||
#[cfg(not(any(target_os = "windows", test, feature = "test-support")))]
|
||||
pub async fn load_direnv_environment(
|
||||
env: &HashMap<String, String>,
|
||||
dir: &Path,
|
||||
) -> Result<HashMap<String, String>, DirenvError> {
|
||||
let Ok(direnv_path) = which::which("direnv") else {
|
||||
return Err(DirenvError::NotFound);
|
||||
};
|
||||
|
||||
let Some(direnv_output) = smol::process::Command::new(direnv_path)
|
||||
.args(["export", "json"])
|
||||
.envs(env)
|
||||
.env("TERM", "dumb")
|
||||
.current_dir(dir)
|
||||
.output()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue