diff --git a/.changes/cli-npx-mobile.md b/.changes/cli-npx-mobile.md new file mode 100644 index 000000000000..973f4fb88fe6 --- /dev/null +++ b/.changes/cli-npx-mobile.md @@ -0,0 +1,6 @@ +--- +'tauri-cli': 'patch:bug' +'@tauri-apps/cli': 'patch:bug' +--- + +Fix `tauri (android|ios) (dev|build)` failing when using `npx tauri` diff --git a/tooling/cli/node/index.js b/tooling/cli/node/index.js index f280ce3b3db5..16777d68d68f 100644 --- a/tooling/cli/node/index.js +++ b/tooling/cli/node/index.js @@ -21,7 +21,7 @@ function isMusl() { // For Node 10 if (!process.report || typeof process.report.getReport !== 'function') { try { - const lddPath = require('child_process').execSync('which ldd').toString().trim(); + const lddPath = require('child_process').execSync('which ldd').toString().trim() return readFileSync(lddPath, 'utf8').includes('musl') } catch (e) { return true diff --git a/tooling/cli/src/build.rs b/tooling/cli/src/build.rs index fa2ab2755069..fd65e245afcc 100644 --- a/tooling/cli/src/build.rs +++ b/tooling/cli/src/build.rs @@ -269,7 +269,7 @@ pub fn setup(options: &mut Options, mobile: bool) -> Result { .any(|ch| !(ch.is_alphanumeric() || ch == '-' || ch == '.')) { error!( - "The bundle identifier \"{}\" set in `{} > tauri > bundle > identifier`. The bundle identifier string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-), and periods (.).", + "The bundle identifier \"{}\" set in `{} > tauri > bundle > identifier`. The bundle identifier string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.).", config_.tauri.bundle.identifier, bundle_identifier_source ); diff --git a/tooling/cli/src/mobile/init.rs b/tooling/cli/src/mobile/init.rs index 9c15c2615ad3..6d903d6c6478 100644 --- a/tooling/cli/src/mobile/init.rs +++ b/tooling/cli/src/mobile/init.rs @@ -130,20 +130,26 @@ pub fn exec( if r.is_match(&bin_stem) { if let Some(npm_execpath) = var_os("npm_execpath").map(PathBuf::from) { let manager_stem = npm_execpath.file_stem().unwrap().to_os_string(); - binary = if manager_stem == "npm-cli" { + let is_npm = manager_stem == "npm-cli"; + let is_npx = manager_stem == "npx-cli"; + binary = if is_npm { "npm".into() + } else if is_npx { + "npx".into() } else { manager_stem }; - if !build_args.is_empty() { + if !(build_args.is_empty() || is_npx) { // remove script path, we'll use `npm_lifecycle_event` instead build_args.remove(0); } - if binary == "npm" { + if is_npm { build_args.insert(0, "--".into()); } - build_args.insert(0, var("npm_lifecycle_event").unwrap()); - if binary == "npm" { + if !is_npx { + build_args.insert(0, var("npm_lifecycle_event").unwrap()); + } + if is_npm { build_args.insert(0, "run".into()); } }