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] tauri-build build script always rebuild if tauri.conf.json is missing #8721

Closed
CrendKing opened this issue Jan 31, 2024 · 5 comments
Closed
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@CrendKing
Copy link

CrendKing commented Jan 31, 2024

Describe the bug

When only using Tauri.toml for the config file, the build script always rebuilds the final executable even nothing is changed. This is due to the usage of unconditional cargo:rerun-if-changed=tauri.conf.json in the build function. Since there is no tauri.conf.json file, and rerun-if-changed considers missing file the same as "stale file", it always triggers the rerun.

Removing the unconditional println!("cargo:rerun-if-changed=tauri.conf.json") line, or placing a duplicate tauri.conf.json in the project bypasses the problem.

Reproduction

Simply switch to use the Tauri.toml file (and of course the config-toml feature). Build the project, then build it again without changing anything.

Expected behavior

There should be no rebuild triggering.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 X64
    ✔ WebView2: 121.0.2277.83
    ✔ MSVC: Visual Studio Build Tools 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 (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.11.0
    - pnpm: 8.15.1
    - npm: 10.2.4

[-] Packages
    - tauri-cli [RUST]: 2.0.0-alpha.21

Stack trace

No response

Additional context

I think the default tauri.conf.json should have its own feature, just like config-toml, and make it default in Cargo. Then we can conditionally include the rerun line with a #[cfg(feature)].

@CrendKing CrendKing added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jan 31, 2024
@naman-crabnebula
Copy link
Contributor

naman-crabnebula commented Feb 1, 2024

In my opinion, adding an empty tauri.conf.json file at the build time would be a better option, because tauri.conf.json is the default config file, and the tauri.toml or tauri.conf.json5 are just additional features.

So, if a user deletes the tauri.conf.json file.

And thanks for reporting the bug btw.

@CrendKing
Copy link
Author

In principle, I really dislike ambiguous logic/environment/etc, because it causes confusion. 3 months later when I revisit this project and see both tauri.conf.json and Tauri.toml, especially the former being {} (but can't be completely empty because then the build complains unable to parse JSON Tauri config file at <path>\src-tauri\tauri.conf.json because EOF while parsing a value at line 1 column 0 for some reason), I will force myself to spend some time recollect the memory we are having here. I will have to ask myself why there are two config files where one is completely unused just for arbitrary Tauri rule that can be found nowhere else.

But if you guys really want to keep the empty tauri.conf.json, please document this behavior in https://tauri.app/v1/references/configuration-files. There is currently no mentioning that by switching the non-default option and deleting the old file, it causes side-effect.

@naman-crabnebula
Copy link
Contributor

But if you guys really want to keep the empty tauri.conf.json, please document this behavior in https://tauri.app/v1/references/configuration-files. There is currently no mentioning that by switching the non-default option and deleting the old file, it causes side-effect

Yeah, because that's a bug 😅

Don't worry, we will fix it ASAP and consider all the odds.

Thank You

@amrbashir
Copy link
Member

I think the default tauri.conf.json should have its own feature, just like config-toml, and make it default in Cargo. Then we can conditionally include the rerun line with a #[cfg(feature)].

I agree, this should be the solution

amrbashir added a commit that referenced this issue Feb 2, 2024
This allows disabling rebuilding when `tauri.conf.json` when using another config format

see #8721
@CrendKing
Copy link
Author

Actually, according to my test, if tauri.conf.json exists, Tauri will completely ignore the config-toml feature, and always use tauri.conf.json. So having an empty tauri.conf.json won't work. It needs to be an exact duplicate at the moment.

I see you are making #8732. Thank you so much! However, I do not know where in tauri-build is the logic that the presence of tauri.conf.json overrides everything. It might be a potential source of bug. Just FYI.

lucasfernog added a commit that referenced this issue Feb 2, 2024
* feat(tauri-build): add `config-json` feature flag

This allows disabling rebuilding when `tauri.conf.json` when using another config format

see #8721

* document feature flag

* Update .changes/tauri-build-config-json.md [skip ci]

* Update core/tauri/src/lib.rs [skip ci]

* disable default features for tauri-build on tauri, plugins

* fmt

---------

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

3 participants