[bug] Relative paths in version
field of tauri.config.json
is not correctly parsed by generate_context!()
since fa028ebf
#4723
Labels
Describe the bug
The
version
field should accept paths topackage.json
. This works with the default directory layout as is generated bycreate-tauri-app
, but may fail incli.js>=1.0.3
when the layout is changed.Reproduction
Clone this repository: https://github.com/shniubobo/tauri-cwd-bug
cd
into it, andIt fails with
And run:
It still fails.
And run:
It now succeeds.
Expected behavior
Step two and three should succeed.
Platform and versions
Environment › OS: Windows 10.0.19044 X64 › Webview2: 103.0.1264.62 › MSVC: - Visual Studio Community 2022 › Node.js: 18.6.0 › npm: 8.13.2 › pnpm: 7.5.2 › yarn: 1.22.19 › rustup: 1.25.1 › rustc: 1.62.0 › cargo: 1.62.0 › Rust toolchain: stable-x86_64-pc-windows-msvc Packages WARNING: no lock files found, defaulting to npm › @tauri-apps/cli [NPM]: 1.0.3 (outdated, latest: 1.0.4) › @tauri-apps/api [NPM]: Not installed! › tauri [RUST]: 1.0.4, › tauri-build [RUST]: 1.0.4, › tao [RUST]: 0.12.1, › wry [RUST]: 0.19.0, App App directory structure ├─ .git ├─ node_modules ├─ src └─ target
Stack trace
No response
Additional context
Please note that the bug affects
generate_context!()
only. The build script does not fail, which means it can correctly parse the relative path. As an aside, if a non-existing path were provided, the build script would fail:The bug is introduced by commit fa028eb.
Before this commit, the config is parsed only by
cli.js
. It always sets the working directory to wheretauri.config.json
is (see below), so it can successfully parse the relative path.tauri/tooling/cli/src/dev.rs
Line 85 in 635f23b
After this commit, however, the config is parsed partly by
cli.js
, and partly bytauri_codegen::get_config
. The working directory is not set before the latter is called bygenerate_context
, and therefore the relative path cannot be parsed.I am working on a fix now, and I will create a PR afterwards.
The text was updated successfully, but these errors were encountered: