Skip to content

fix(utils): keep the drive prefix of absolute resource paths on Windows - #16453

Merged
Legend-Master merged 3 commits into
tauri-apps:devfrom
b84330808:fix-resource-path-drive-prefix
Nov 5, 2026
Merged

Legend-Master merged 3 commits into
tauri-apps:devfrom
b84330808:fix-resource-path-drive-prefix

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

The resource path iterator in tauri-utils runs every non-glob pattern and every walked or globbed entry through normalize, which dropped Component::Prefix. On Windows that turns D:\assets\icon.png into \assets\icon.png, a path that resolves against the drive of the current directory. So when bundle > resources (list or map) or bundle > externalBin points at an absolute path on another drive than the project, for example D:/assets/icon.png in a project on C:, tauri-build and the bundler fail with:

resource path `/assets\icon.png` doesn't exist

This happens for a file, a directory and a glob pattern. On the same drive it happened to work, but the returned Resource::path() had no drive letter.

This keeps the prefix (and pushes the root as the component itself, so the path stays a native one). Unix paths have no prefix, so nothing changes there. Added resource_paths_iter_map_absolute_paths, which fails on Windows without the fix, and a change file for tauri-utils.

I used Claude Code to write this change.

`normalize` in the resource path iterator dropped `Component::Prefix`,
so `D:\assets\icon.png` became `\assets\icon.png`, which Windows
resolves against the drive of the current directory. A resource,
glob or external binary on another drive than the project failed with
`ResourcePathNotFound`, and one on the same drive was returned without
its drive letter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Package Changes Through 6331742

There are 7 changes which include @tauri-apps/api with patch, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri with patch, tauri-runtime-wry with patch, tauri-utils with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.12.4 2.12.5
tauri-utils 2.10.2 2.10.3
tauri-bundler 2.10.4 2.10.5
tauri-runtime 2.12.2 2.12.3
tauri-runtime-wry 2.12.3 2.12.4
tauri-codegen 2.7.4 2.7.5
tauri-macros 2.7.4 2.7.5
tauri-plugin 2.7.2 2.7.3
tauri-build 2.7.4 2.7.5
tauri 2.12.5 2.12.6
@tauri-apps/cli 2.12.4 2.12.5
tauri-cli 2.12.4 2.12.5

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

let mut dest = PathBuf::new();
for component in path.components() {
match component {
Component::Prefix(_) => {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, do we even support this use case at all (from another drive on Windows)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute paths are documented for bundle > resources (the config docs show /absolute/path/to/textfile.txt), and resource_relpath already handles the prefix and root components. On Windows an absolute path always has a drive, so dropping it only works when the file is on the same drive as the project; from another drive the file is not found. If other drives should not be supported, I can change this to return a clear error instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they should be supported but we can't change our resource_relpath easily or it's a breaking change. Just supporting them here doesn't seem to be enough?

@lucasfernog do you still have memory on why we stripped the prefix here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Legend-Master i think this was just inherited from cargo-bundle
i think we can scope the fix to normalize alone though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR already only changes normalize(); resource_relpath is untouched, so bundle target paths stay the same.

Comment thread crates/tauri-utils/src/resources.rs Resolved

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Legend-Master
Legend-Master merged commit a1ea1b5 into tauri-apps:dev Nov 5, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants