You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this doesn't work for some commands like dev and build because these commands set the current directory to src-tauri before running the code that relies on get_app_dir(). Then the get_app_dir() search starts in src-tauri instead of the working directory where the command was run.
The command info does not have this issue, because it does not change the current working directory before running.
I am not sure if layouts like this one are supposed to be supported, but I think the behavior of the CLI should at least be consistent across commands. I was going to open a PR for this, but I didn't know how much stuff in the CLI relies on the stateful changing of the current working directory...
Reproduction
Create a new project: npm create tauri-app@latest -- --beta (I chose: TypeScript/React/npm/no mobile)
Create a new directory inside the project called src-web, move all web-related sources into this directory
Run cargo tauri dev
Output:
Running BeforeDevCommand (`npm run dev`)
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\git\iQ-Next\package.json
npm ERR! errno -4058
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'C:\git\tauri-test\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in: C:\Users\samuel.kearney\AppData\Local\npm-cache\_logs\2024-07-29T18_03_00_167Z-debug-0.log
Error The "beforeDevCommand" terminated with a non-zero status code.
Describe the bug
Consider the following project layout:
It seems like the tauri CLI is written to be flexible to different project layouts such as this one. This is based on what I see primarily in https://github.com/tauri-apps/tauri/blob/dev/tooling/cli/src/helpers/app_paths.rs; in
get_app_dir()
there is some logic to walk subdirectories until finding apackage.json
file.However, this doesn't work for some commands like
dev
andbuild
because these commands set the current directory tosrc-tauri
before running the code that relies onget_app_dir()
. Then theget_app_dir()
search starts insrc-tauri
instead of the working directory where the command was run.The command
info
does not have this issue, because it does not change the current working directory before running.I am not sure if layouts like this one are supposed to be supported, but I think the behavior of the CLI should at least be consistent across commands. I was going to open a PR for this, but I didn't know how much stuff in the CLI relies on the stateful changing of the current working directory...
Reproduction
npm create tauri-app@latest -- --beta
(I chose: TypeScript/React/npm/no mobile)src-web
, move all web-related sources into this directorycargo tauri dev
Output:
Expected behavior
Dev server starts successfully
Full
tauri info
outputStack trace
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: