fix(cli): mobile init when using pnpm dlx (#14118)

i noticed this when testing #13180 (though the original issue refers to npx, which I could not reproduce yet)
This commit is contained in:
Lucas Fernandes Nogueira
2025-10-06 13:12:00 -03:00
committed by GitHub
parent b0012424c5
commit abf7e8850b
2 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@tauri-apps/cli": patch:bug
"tauri-cli": patch:bug
---
Fixes mobile project initialization when using `pnpx` or `pnpm dlx`.

View File

@@ -79,6 +79,8 @@ pub fn exec(
if r.is_match(&bin_stem.to_string_lossy()) {
if var_os("PNPM_PACKAGE_NAME").is_some() {
return ("pnpm".into(), build_args);
} else if is_pnpm_dlx() {
return ("pnpm".into(), vec!["dlx", "@tauri-apps/cli"]);
} else if let Some(npm_execpath) = var_os("npm_execpath") {
let manager_stem = PathBuf::from(&npm_execpath)
.file_stem()
@@ -368,3 +370,17 @@ fn unprefix_path(
)
.map_err(Into::into)
}
fn is_pnpm_dlx() -> bool {
var_os("NODE_PATH")
.map(PathBuf::from)
.is_some_and(|node_path| {
let mut iter = node_path.components().peekable();
while let Some(c) = iter.next() {
if c.as_os_str() == "pnpm" && iter.peek().is_some_and(|c| c.as_os_str() == "dlx") {
return true;
}
}
false
})
}