Skip to content

Commit b839212

Browse files
authored
fix(cli): ios command wrong cwd on bun 1.2, closes #12965 (#12977)
bun 1.2 changed the current working directory behavior to match NPM managers, so we must adapt our xcode-script logic to check the bun version see https://bun.sh/blog/bun-v1.2#bun-run-uses-the-correct-directory
1 parent 3cc4ad3 commit b839212

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changes/fix-ios-bun-1.2.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:bug
3+
"@tauri-apps/cli": patch:bug
4+
---
5+
6+
Fix `tauri ios` commands using the wrong working directory with `bun@>1.2`.

crates/tauri-cli/src/mobile/ios/xcode_script.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ pub fn command(options: Options) -> Result<()> {
6565
}
6666
}
6767

68-
// `xcode-script` is ran from the `gen/apple` folder when not using NPM.
68+
// `xcode-script` is ran from the `gen/apple` folder when not using NPM/yarn/pnpm.
6969
// so we must change working directory to the src-tauri folder to resolve the tauri dir
70+
// additionally, bun@<1.2 does not modify the current working directory, so it is also runs this script from `gen/apple`
71+
// bun@>1.2 now actually moves the CWD to the package root so we shouldn't modify CWD in that case
72+
// see https://bun.sh/blog/bun-v1.2#bun-run-uses-the-correct-directory
7073
if (var_os("npm_lifecycle_event").is_none() && var_os("PNPM_PACKAGE_NAME").is_none())
71-
|| var("npm_config_user_agent").is_ok_and(|agent| agent.starts_with("bun"))
74+
|| var("npm_config_user_agent")
75+
.is_ok_and(|agent| agent.starts_with("bun/1.0") || agent.starts_with("bun/1.1"))
7276
{
7377
set_current_dir(current_dir()?.parent().unwrap().parent().unwrap()).unwrap();
7478
}

0 commit comments

Comments
 (0)