scaffolding icon indicating copy to clipboard operation
scaffolding copied to clipboard

[BUG] Scaffolding A Zome Fails on Windows Due to Path Canonicalization Issue

Open ClayAmore opened this issue 11 months ago • 2 comments

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.0 and any version above

Steps to reproduce

  1. Ensure extended-length path support is enabled on Windows.
  2. 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
  1. 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)?;

ClayAmore avatar Dec 27 '24 16:12 ClayAmore

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.

c12i avatar Jan 07 '25 15:01 c12i

replace canonicalize by dunce::canonicalize

This is an edge case anyway, regular paths are working under Windows directly.

jost-s avatar Jan 15 '25 16:01 jost-s