IJPL-442: ensure windows app data env vars are set

consistent with the old launcher behaviour

GitOrigin-RevId: 92fd4fb62e6687979b979037eca48ab56b2d2611
This commit is contained in:
Ivan Pashchenko
2024-03-28 15:30:06 +00:00
committed by intellij-monorepo-bot
parent 4a2660db61
commit 70d4bb1db8
+17
View File
@@ -110,6 +110,8 @@ fn main_impl(exe_path: PathBuf, remote_dev: bool, debug_mode: bool) -> Result<()
}
debug!("Current directory: {:?}", env::current_dir());
ensure_env_vars_set()?;
debug!("** Preparing launch configuration");
let configuration = get_configuration(remote_dev, &exe_path.strip_ns_prefix()?).context("Cannot detect a launch configuration")?;
@@ -130,6 +132,21 @@ fn main_impl(exe_path: PathBuf, remote_dev: bool, debug_mode: bool) -> Result<()
Ok(())
}
#[cfg(target_os = "windows")]
fn ensure_env_vars_set() -> Result<()> {
let app_data = get_known_folder_path(&Shell::FOLDERID_RoamingAppData, "FOLDERID_RoamingAppData")?;
env::set_var("APPDATA", &app_data.strip_ns_prefix()?.to_string_checked()?);
let local_app_data = get_known_folder_path(&Shell::FOLDERID_LocalAppData, "FOLDERID_LocalAppData")?;
env::set_var("LOCALAPPDATA", &local_app_data.strip_ns_prefix()?.to_string_checked()?);
Ok(())
}
#[cfg(not(target_os = "windows"))]
fn ensure_env_vars_set() -> Result<()> {
Ok(())
}
#[cfg(target_os = "macos")]
fn restore_working_directory() -> Result<()> {
let (cwd_res, pwd_var) = (env::current_dir(), env::var("PWD"));