Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] trunk serve causes cargo tauri to rebuild which causes trunk serve to rebuild #160

Closed
kornelski opened this issue Sep 4, 2022 · 1 comment

Comments

@kornelski
Copy link

Describe the bug

If I run cargo tauri dev and trunk serve at the same time, they both watch the same folder for changes, and detect changes to temporary files from the other tool's build, so they both endlessly keep triggering rebuilds.

OTOH If I don't run trunk serve myself, then cargo tauri dev is stuck waiting forever:

Warn Waiting for your frontend dev server to start on http://localhost:1420/...
Warn Waiting for your frontend dev server to start on http://localhost:1420/...
Warn Waiting for your frontend dev server to start on http://localhost:1420/...

Also, when these projects rebuild, they rebuild almost from scratch. I think it's because both end up using the same target/ folder and overwrite each other's build artifacts due to differences in cargo feature flags they use.

Reproduction

npm create tauri-app
# choose cargo and yew
cd the-app
cargo tauri dev 

and then run

trunk serve

in another terminal in the same dir.

Expected behavior

Ideally cargo tauri dev should start the server, so that a separate trunk command is not needed.

Platform and versions

Environment
› OS: Mac OS 12.5.1 X64
› Node.js: 18.8.0
› npm: 8.18.0
› pnpm: Not installed!
› yarn: 1.22.19
› rustup: 1.25.1
› rustc: 1.63.0
› cargo: 1.63.0
› Rust toolchain: stable-aarch64-apple-darwin

Packages
WARNING: no lock files found, defaulting to npm
› @tauri-apps/cli [NPM]: 1.0.5
› @tauri-apps/api [NPM]: Not installed!
› tauri [RUST]: 1.0.5,
› tauri-build [RUST]: 1.0.4,
› tao [RUST]: 0.12.2,
› wry [RUST]: 0.19.0,

App
› build-type: bundle
› CSP: unset
› distDir: ../dist
› devPath: http://localhost:1420/
package.json not found

App directory structure
├─ dist
├─ target
├─ public
├─ src-tauri
├─ .vscode
└─ src

Stack trace

No response

Additional context

No response

@amrbashir
Copy link
Member

If I run cargo tauri dev and trunk serve at the same time, they both watch the same folder for changes, and detect changes to temporary files from the other tool's build, so they both endlessly keep triggering rebuilds.

The yew template has .taurignore to stop tauri-cli from retriggering builds whenever yew files change but the CLI version that supports this, is not released yet (you can use the tauri-cli from git for now cargo install --git https://github.com/tauri-apps/tauri --branch dev tauri-cli).
Unfortunately I didn't configure trunk to do the same. I will push an update shortly for this but for the mean time in your Trunk.toml add this:

[watch]
ignore = ["./src-tauri"]

OTOH If I don't run trunk serve myself, then cargo tauri dev is stuck waiting forever:

you shouldn't need to run trunk yourself. cargo tauri dev should start it for you. This probably because beforeDevCommand in tauri.conf.json is not configured correctly so double check that. This was a bug on our end which was fixed in https://github.com/tauri-apps/create-tauri-app/releases/tag/create-tauri-app-v2.1.1

Also, when these projects rebuild, they rebuild almost from scratch. I think it's because both end up using the same target/ folder and overwrite each other's build artifacts due to differences in cargo feature flags they use.

I wasn't able to reproduce this, at least not with trunk configured correctly to ignore src-tauri and .taurignore configured to ignore yew files.

@amrbashir amrbashir transferred this issue from tauri-apps/tauri Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants