Repository navigation
fix(utils): keep the drive prefix of absolute resource paths on Windows - #16453
Conversation
`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]>
Package Changes Through 6331742There 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 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 |
| let mut dest = PathBuf::new(); | ||
| for component in path.components() { | ||
| match component { | ||
| Component::Prefix(_) => {} |
There was a problem hiding this comment.
Actually, do we even support this use case at all (from another drive on Windows)?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@Legend-Master i think this was just inherited from cargo-bundle
i think we can scope the fix to normalize alone though
There was a problem hiding this comment.
This PR already only changes normalize(); resource_relpath is untouched, so bundle target paths stay the same.
Co-authored-by: Tony <[email protected]>
The resource path iterator in
tauri-utilsruns every non-glob pattern and every walked or globbed entry throughnormalize, which droppedComponent::Prefix. On Windows that turnsD:\assets\icon.pnginto\assets\icon.png, a path that resolves against the drive of the current directory. So whenbundle > resources(list or map) orbundle > externalBinpoints at an absolute path on another drive than the project, for exampleD:/assets/icon.pngin a project onC:,tauri-buildand the bundler fail with: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 fortauri-utils.I used Claude Code to write this change.