Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/mobile-pnpm-dlx-init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tauri-apps/cli": patch:bug
"tauri-cli": patch:bug
---

Fixes mobile project initialization when using `pnpx` or `pnpm dlx`.
16 changes: 16 additions & 0 deletions crates/tauri-cli/src/mobile/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
})
}
Loading