fix(cli): Fix mixup of TAURI_APP_PATH and TAURI_FRONTEND_PATH - #11492
Conversation
…n tauri's path resolutions
…y exposed env var keys
|
These are the exact steps I followed to test the PR on a minimal dummy project, with the following custom structure:
|
Package Changes Through 704bc06There are 6 changes which include tauri with patch, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri-runtime-wry with patch, @tauri-apps/api with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
0947a3b to
704bc06
Compare
lucasfernog
left a comment
There was a problem hiding this comment.
oh nice catch, I didn't realize i swapped the vars :/
This PR aims to fix a mixup that happened prior to merging #11258, as a result of which the newly introduced env vars
TAURI_APP_PATHandTAURI_FRONTEND_PATHhave to be used incorrectly (i.e. swapped), in order for path customization to work:The cause of this unfortunate last-minute mixup came from a rename aimed at avoiding confusion, applied in 8af2d51, which I unfortunately didn't catch from @lucasfernog's description:
Originally posted by @lucasfernog in #11258 (comment)
This PR fixes this mixup.
The initial names' use of "app" + "src" were potentially confusing as one could consider both, the frontend and the tauri directories to be "app" directories, which in turn both contain "src" sub-directories. Not good.
I fear however that (even with this fix in place) the rename to "frontend" + "app" might have just replaced one source of confusion with another, at least within
tauri-cli's own code:Looking into
/crates/tauri-cli/src/*it seems as if the name most-commonly used used for the directory thatTAURI_FRONTEND_PATHaims to provide a customization hook for (i.e. the directory containingpackage.json), isapp_dir/app_path, while the corresponding name forTAURI_APP_PATH(i.e. the directory containingtauri.config.toml) tends to betauri_dir/tauri_path: The exact opposite of each other.As such I took the liberty of applying a few more renames (
app_dir/app_path=>frontend_dir/frontend_path) to re-align things withintauri-cli/src(but kept them in separate PRs for easier code review).I have tested the patched
cargo-tauritool on a real-world project and it works, again.Where by "it works" I mean that the following works:
If you do provide appropriate env vars, then you can now run the command from the project's "tauri" directory, despite the project having a non-standard structure:
✅
(Worth noting: Running
cargo tauri devfrom within the tauri directory has always worked, even before the introduction of such env vars, if you made some changes to thebeforeDevCommandandbeforeBuildCommandtauri configs. As such it used to be how we would build/run out tauri app.)Likewise, if you do provide appropriate env vars, then you can now even run the command from the project's root(!) directory:
✅
Likewise running
pnpm taurifrom within the "frontend" directory should work, too:❓
I don't however know how to patch the node side of
cargo tauri, so I'll have to leave any testing of that to you.