[BUG] Scaffolding A Zome Fails on Windows Due to Path Canonicalization Issue
Description
Scaffolding a zome fails on Windows due to issues with path canonicalization. The extended-length path prefix \\?\ remains in the path, which prevents the scaffolding tool from executing correctly. This issue occurs in the following function:
src\scaffold\app\cargo.rs::exec_metadata
The error message that appears is:
failed to load manifest for workspace member `\\?\C:\rust\test-app\dnas\*\zomes\coordinator\*`
referenced by workspace at `\\?\C:\rust\test-app\Cargo.toml`
Caused by:
failed to read `\\?\C:\rust\test-app\dnas\*\zomes\coordinator\*\Cargo.toml`
Caused by:
Filnavnet, mappenavnet eller volumnavnesyntaksen er feil. (os error 123)
`cargo metadata` exited with an error:
Expected behavior
The canonicalized path should not retain the \\?\ extended-length path prefix, allowing the tool to execute successfully.
System information
- OS: [Windows 10]
- Scaffolding Version:
4.0.0and any version above
Steps to reproduce
- Ensure extended-length path support is enabled on Windows.
- Use the scaffolding tool to create a new web app and add a DNA and zome:
hc scaffold web-app`
cd {web-app-name}
hc scaffold dna
hc scaffold zome
- The following error will occur:
failed to load manifest for workspace member `\\?\C:\rust\test-app\dnas\*\zomes\coordinator\*`
referenced by workspace at `\\?\C:\rust\test-app\Cargo.toml`
Caused by:
failed to read `\\?\C:\rust\test-app\dnas\*\zomes\coordinator\*\Cargo.toml`
Caused by:
Filnavnet, mappenavnet eller volumnavnesyntaksen er feil. (os error 123)
`cargo metadata` exited with an error:
Possible fix
To resolve this issue, the dunce crate can be used for path canonicalization, which avoids the extended-length path prefix.
Current code
src\scaffold\app\cargo.rs:161
let path = current_dir
.join(workspace_cargo_toml_path(app_file_tree))
.canonicalize()?;
Proposed fix:
let path = current_dir.join(workspace_cargo_toml_path(app_file_tree));
let path = dunce::canonicalize(path)?;
Hey @ClayAmore thanks for opening the issue and you suggestion. We have not been able to reproduce this bug unfortunately, so we need to gather more information before implementing the proposed fix. In the meantime, I recommend using WSL for development on Windows, to avoid similar path-related issues.
replace canonicalize by dunce::canonicalize
This is an edge case anyway, regular paths are working under Windows directly.