tauri
tauri copied to clipboard
tauri android init internal error: entered unreachable code: abs_src and abs_dest have no common root
Describe the bug
internal error: entered unreachable code: abs_src and abs_dest have no common root
Reproduction
No response
Expected behavior
No response
Full tauri info
output
internal error: entered unreachable code: abs_src and abs_dest have no common root
Stack trace
No response
Additional context
No response
Can you please share your project structure?
I meet the same problem.
The abs_src is "C:\Users\33028\.cargo\bin\cargo-tauri.exe",
but the abs_dest is "D:\project\sars-mobile\src-tauri".
The error is from cargo-mobile>src>util>path>common_root: unreachable!("abs_src
and abs_dest
have no common root");
If I move my project to disk C, the error disappared.
I think I should not store project to DISK C, so is this a BUG?
fn common_root(abs_src: &Path, abs_dest: &Path) -> PathBuf {
println!("abs_src: {:?}", abs_src);
println!("abs_dest: {:?}", abs_dest);
let mut dest_root = abs_dest.to_owned();
loop {
if abs_src.starts_with(&dest_root) {
return dest_root;
} else if !dest_root.pop() {
unreachable!("abs_src
and abs_dest
have no common root");
}
}
}
Please provide steps to reproduce and tauri info
output
Hi I have the same issue when I am running yarn tauri android init
on Windows 11 , no issues on Mac machine.
For reference yarn tauri info
`
[✔] Environment
- OS: Windows 10.0.22631 X64
✔ WebView2: 120.0.2210.133
✔ MSVC:
- Visual Studio Build Tools 2019
- Visual Studio Community 2022
✔ rustc: 1.75.0 (82e1608df 2023-12-21)
✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.11.0
- pnpm: 8.14.1
- yarn: 1.22.21
- npm: 10.3.0
[-] Packages - tauri [RUST]: 2.0.0-alpha.20 - tauri-build [RUST]: 2.0.0-alpha.13 - wry [RUST]: 0.35.2 - tao [RUST]: 0.24.0 - @tauri-apps/api [NPM]: 2.0.0-alpha.13 - @tauri-apps/cli [NPM]: 2.0.0-alpha.20
[-] App - build-type: bundle - CSP: unset - distDir: ../dist/tauri-sh-app/browser - devPath: http://localhost:1420/ - framework: Angular - bundler: Webpack ` Could you please advice if any solutions?
I'm getting the same error in windows when my project isn't on disk C:
When the project is on C: - one of the messages says
Info "C:\\Program Files\\nodejs\\node.exe" relative to "C:\\proj\\thingy\\src-tauri" is "..\\..\\..\\Program Files\\nodejs\\node.exe"
So looks like it's trying to get a relative path from your project to nodejs executable.
On windows, if they are both on different disks - this is impossible so it panics.
tauri info:
[✔] Environment
- OS: Windows 10.0.22621 X64
✔ WebView2: 121.0.2277.98
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.75.0 (82e1608df 2023-12-21)
✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.11.0
- yarn: 1.22.21
- npm: 10.2.4
[-] Packages
- tauri [RUST]: 2.0.0-beta.2
- tauri-build [RUST]: 2.0.0-beta.1
- wry [RUST]: 0.35.2
- tao [RUST]: 0.25.0
- @tauri-apps/api [NPM]: 2.0.0-beta.0
- @tauri-apps/cli [NPM]: 2.0.0-beta.1
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- framework: React
- bundler: Vite
Same issue. Steps to reproduce:
D:\TEMP>yarn create tauri-app --alpha
➤ YN0000: · Yarn 4.1.0
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + create-tauri-app@npm:3.13.3, create-tauri-app-darwin-arm64@npm:3.13.3, and 9 more.
➤ YN0000: └ Completed in 0s 242ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 2 packages were added to the project (+ 1016.2 KiB).
➤ YN0000: └ Completed in 0s 214ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in 0s 549ms
warning: The `--alpha` option is now an alias for `--beta` and may be removed in the future.
✔ Project name · tauri-app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
✔ Choose your package manager · yarn
✔ Choose your UI template · Svelte - (https://svelte.dev/)
✔ Choose your UI flavor · TypeScript
✔ Would you like to setup the project for mobile as well? · yes
Template created! To get started run:
cd tauri-app
yarn
yarn tauri android init
For Desktop development, run:
yarn tauri dev
For Android development, run:
yarn tauri android dev
D:\TEMP>cd tauri-app
D:\TEMP\tauri-app>code.
'code.' is not recognized as an internal or external command,
operable program or batch file.
D:\TEMP\tauri-app>code .
Then in VS Code:
PS D:\TEMP\tauri-app> yarn
➤ YN0000: · Yarn 4.1.0
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @sveltejs/vite-plugin-svelte@npm:3.0.2, @tauri-apps/api@npm:2.0.0-beta.0, @tauri-apps/cli@npm:2.0.0-beta.1, @tauri-apps/plugin-shell@npm:2.0.0-beta.0, @tsconfig/svelte@npm:5.0.2, internal-ip@npm:7.0.0, svelte-check@npm:3.6.4, svelte@npm:4.2.10, tslib@npm:2.6.2, and 241 more.
➤ YN0000: └ Completed in 5s 525ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 206 packages were added to the project (+ 117.89 MiB).
➤ YN0000: └ Completed in 2s 881ms
➤ YN0000: ┌ Link step
➤ YN0007: │ esbuild@npm:0.19.12 must be built because it never has been before or the last one failed
➤ YN0007: │ svelte-preprocess@npm:5.1.3 [de3c9] must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 1s 268ms
➤ YN0000: · Done in 9s 745ms
PS D:\TEMP\tauri-app> yarn tauri android init
thread '<unnamed>' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cargo-mobile2-0.8.0\src\util\path.rs:136:13:
internal error: entered unreachable code: `abs_src` and `abs_dest` have no common root
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
PS D:\TEMP\tauri-app>
[✔] Environment - OS: Windows 10.0.22621 X64 ✔ WebView2: 116.0.1938.76 ✔ MSVC: Visual Studio Community 2022 ✔ rustc: 1.76.0 (07dca489a 2024-02-04) ✔ cargo: 1.76.0 (c84b36747 2024-01-18) ✔ rustup: 1.26.0 (5af9b9484 2023-04-05) ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
[-] Packages - tauri [RUST]: 2.0.0-beta.6 - tauri-build [RUST]: 2.0.0-beta.4 - wry [RUST]: 0.37.0 - tao [RUST]: 0.26.0 - tauri-cli [RUST]: 2.0.0-beta.4 - @tauri-apps/api : not installed! - @tauri-apps/cli [NPM]: 2.0.0-beta.4
[-] App - build-type: bundle - CSP: unset - frontendDist: ../src
Could any of you who face this issue provide the directory structure of your drive, if possible with .gitignore if any exists, for example:
C:/
|_ some-dir
|_ .gitignore
|_ some-another-dir
|_ my-tauri-app
Could any of you who face this issue provide the directory structure of your drive, if possible with .gitignore if any exists, for example:
As i said above, the problem happens when your node executable is not on the same drive as your project.
For me tauri project is in G:\ruststuff\tauritest
node is C:\Program Files\nodejs\node.exe
I have a gitignore in G:\ruststuff\tauritest
(the default one created by yarn create tauri-app --alpha --template react-ts
)
There is no common root between different disks and it crashes with that "entered unreachable code" error.
If the project is anywhere on C: it works correctly.
I have a similar project structure and it worked fine, could you maybe run with --verbose
flag, maybe it has more info
G:\ruststuff\tauritest>yarn tauri android init --verbose
yarn run v1.22.21
$ tauri android init --verbose
thread '<unnamed>' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cargo-mobile2-0.10.2\src\util\path.rs:136:13:
internal error: entered unreachable code: `abs_src` and `abs_dest` have no common root
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Done in 1.42s.
@amrbashir are you on windows and is your project on a different disk than your nodejs.exe ?
The code that panics is here - https://github.com/tauri-apps/cargo-mobile2/blob/dev/src/util/path.rs#L130-L164
To me it looks like it assumes a posix filesystem that has one common root for everything, on windows it's not true so it gets into that "unreachable" branch.
@amrbashir are you on windows and is your project on a different disk than your nodejs.exe ?
yes, also not sure why it is trying to find nodejs.exe
.
Finally, I can reproduce it, the issue seems to only happen with yarn
and cargo
as well, will look into this.
@amrbashir are you on windows and is your project on a different disk than your nodejs.exe ?
yes, also not sure why it is trying to find
nodejs.exe
.
I think it's this code: https://github.com/tauri-apps/tauri/blob/5a19147b06d03e7877ed2291e2bc6ff622aa939f/tooling/cli/src/mobile/init.rs#L107-L118
When running from yarn i think it loads the cli as a node module? (through @tauri-apps/cli npm package which then loads @tauri-apps/cli-win32-x64-msvc) so your argv[0] is node.exe
Thanks @bdew for your help, I made a PR to fix this.