Skip to content

Commit bbce99e

Browse files
committed
fix(installer): propagate VP_HOME to child vp processes
When --install-dir overrides the default location, child vp processes (refresh_shims, create_env_files, install_production_deps) would fall back to ~/.vite-plus because VP_HOME was not set in their environment. Set VP_HOME to the resolved install directory before spawning any child processes so they always use the correct location.
1 parent d3b35fb commit bbce99e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

crates/vite_installer/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fn main() {
4242
init_dll_security();
4343

4444
let opts = cli::parse();
45+
4546
let rt = tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap_or_else(|e| {
4647
print_error(&format!("Failed to create async runtime: {e}"));
4748
std::process::exit(1);
@@ -62,6 +63,12 @@ async fn run(mut opts: cli::Options) -> i32 {
6263
};
6364
let install_dir_display = install_dir.as_path().to_string_lossy().to_string();
6465

66+
// Propagate the resolved install directory to child `vp` processes
67+
// (refresh_shims, create_env_files, install_production_deps) so they
68+
// find the correct home, especially for --install-dir overrides.
69+
// Safety: no other threads are reading env vars at this point.
70+
unsafe { std::env::set_var("VP_HOME", install_dir.as_path()) };
71+
6572
// Pre-compute Node.js manager default before showing the menu,
6673
// so the user sees the resolved value and can override it.
6774
if !opts.no_node_manager {

0 commit comments

Comments
 (0)