From 85328fe63c08583876172bd54fc6ca1754ca5376 Mon Sep 17 00:00:00 2001 From: xwbx <1677759063@qq.com> Date: Tue, 9 Jun 2026 15:54:03 +0800 Subject: [PATCH 1/2] fix: use custom registry if exist --- crates/vite_setup/src/install.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/vite_setup/src/install.rs b/crates/vite_setup/src/install.rs index 00824cd20e..dced29c1cf 100644 --- a/crates/vite_setup/src/install.rs +++ b/crates/vite_setup/src/install.rs @@ -284,7 +284,7 @@ pub async fn install_production_deps( format!("pnpm entry not found at {}", pnpm_entry.as_path().display()).into(), )); } - let output = run_pnpm_install(version_dir, &node_runtime, &pnpm_entry, &args).await?; + let output = run_pnpm_install(version_dir, &node_runtime, &pnpm_entry, &args, registry).await?; if !output.status.success() { let log_path = write_upgrade_log(version_dir, &output.stdout, &output.stderr).await; @@ -316,7 +316,7 @@ pub async fn install_production_deps( // Only create the local override after explicit consent. This preserves // minimumReleaseAge protection for the default and non-interactive paths. write_release_age_overrides(version_dir).await?; - let retry_output = run_pnpm_install(version_dir, &node_runtime, &pnpm_entry, &args).await?; + let retry_output = run_pnpm_install(version_dir, &node_runtime, &pnpm_entry, &args, registry).await?; if !retry_output.status.success() { let retry_log_path = write_upgrade_log(version_dir, &retry_output.stdout, &retry_output.stderr).await; @@ -339,6 +339,7 @@ async fn run_pnpm_install( node_runtime: &vite_js_runtime::JsRuntime, pnpm_entry: &AbsolutePath, args: &[&str], + registry: Option<&str>, ) -> Result { let node_bin = node_runtime.get_bin_prefix(); let pnpm_bin = pnpm_entry.parent().ok_or_else(|| { @@ -350,15 +351,18 @@ async fn run_pnpm_install( let path = env::join_paths(path_entries) .map_err(|error| Error::Setup(format!("Failed to build PATH for pnpm: {error}").into()))?; - let output = tokio::process::Command::new(node_runtime.get_binary_path().as_path()) - .arg(pnpm_entry.as_path()) + let mut cmd = tokio::process::Command::new(node_runtime.get_binary_path().as_path()); + cmd.arg(pnpm_entry.as_path()) .args(args) .current_dir(version_dir) .env("CI", "true") - .env("PATH", path) - .output() - .await?; + .env("PATH", path); + + if let Some(registry_url) = registry { + cmd.env("npm_config_registry", registry_url); + } + let output = cmd.output().await?; Ok(output) } From ee83397b75c67fb6240a5744f28ce9db75aacd7e Mon Sep 17 00:00:00 2001 From: xwbx <1677759063@qq.com> Date: Tue, 9 Jun 2026 16:13:48 +0800 Subject: [PATCH 2/2] chore: use vite_shared::env_vars::NPM_CONFIG_REGISTRY --- Cargo.lock | 1 + crates/vite_setup/Cargo.toml | 1 + crates/vite_setup/src/install.rs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index ea75bfef1d..f7e04f0568 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8556,6 +8556,7 @@ dependencies = [ "vite_install", "vite_js_runtime", "vite_path", + "vite_shared", "vite_str", ] diff --git a/crates/vite_setup/Cargo.toml b/crates/vite_setup/Cargo.toml index 741bd09c7a..0fd6e8b931 100644 --- a/crates/vite_setup/Cargo.toml +++ b/crates/vite_setup/Cargo.toml @@ -21,6 +21,7 @@ tracing = { workspace = true } vite_install = { workspace = true } vite_js_runtime = { workspace = true } vite_path = { workspace = true } +vite_shared = { workspace = true } vite_str = { workspace = true } [target.'cfg(windows)'.dependencies] diff --git a/crates/vite_setup/src/install.rs b/crates/vite_setup/src/install.rs index dced29c1cf..a765c1f724 100644 --- a/crates/vite_setup/src/install.rs +++ b/crates/vite_setup/src/install.rs @@ -359,7 +359,7 @@ async fn run_pnpm_install( .env("PATH", path); if let Some(registry_url) = registry { - cmd.env("npm_config_registry", registry_url); + cmd.env(vite_shared::env_vars::NPM_CONFIG_REGISTRY, registry_url); } let output = cmd.output().await?;