Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ClayAmore opened this issue Dec 27, 2024 · 0 comments

Comments

@ClayAmore
Copy link

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)?;
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

No branches or pull requests

1 participant