Skip to content

Conversation

@SmartManoj
Copy link

Ensure dependency names are sanitized by replacing colons with underscores to maintain filesystem compatibility.

Fixes #285

Switches the replacement character from underscore to hyphen when sanitizing dependency names for directory creation, ensuring consistency with wit-deps naming conventions.
Copy link
Member

@rvolosatovs rvolosatovs left a comment

Choose a reason for hiding this comment

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

Thanks! Just one small concern I have is the choice of the separator - I forget, is - a valid character to use in IDs (could you check the spec and ideally add a comment with a reference?)

If - is accepted, could we use some other character, which is disallowed by component model, but would be Windows-path compatible?

_ comes to mind, but I do not have the time to check the spec right now

Clarified comments in the dependency name sanitization process to specify the requirements for WIT identifiers, including kebab-case formatting and compatibility with Windows file systems.
@SmartManoj SmartManoj requested a review from rvolosatovs June 27, 2025 07:03
// WIT identifiers must be kebab-case (words separated by '-') and cannot contain underscores or other punctuation.
// See: https://component-model.bytecodealliance.org/design/wit.html#identifiers
// We use '-' as the separator to match WIT spec and ensure Windows compatibility.
let sanitized_id = id.replace(':', "-");
Copy link
Member

Choose a reason for hiding this comment

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

this would cause a clash between foo:bar-baz and foo-bar:baz, right?

From the linked spec:

Double hyphens (--) are not allowed.

Can we try using -- to work around that?

Copy link
Author

Choose a reason for hiding this comment

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

again you meant double hyphens?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, anything that would be disallowed by the WIT spec and allowed by most OSes, Windows in particular

Copy link
Author

@SmartManoj SmartManoj Jul 15, 2025

Choose a reason for hiding this comment

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

Double hyphens (--) are not allowed.

didn't this mean continuous double hyphens?


foo-bar-baz allowed but not foo--bar?

Copy link
Member

Choose a reason for hiding this comment

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

Right, so I'm thinking if we stored:

  • foo:bar-baz package -> foo--bar-baz directory
  • foo-bar:baz package -> foo-bar--baz directory

Tooling like wit-bindgen would be able to read WIT from these directories and rely on WIT package name (package directive in WIT).
I don't think any component model tooling actually relies on directory names for anything

Copy link
Author

Choose a reason for hiding this comment

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

foo--bar-baz is not allowed because it contains -- (continuous double hyphens)

Copy link
Member

Choose a reason for hiding this comment

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

exactly, that's why we should be able to use that on the file system to avoid duplicates - no WIT package name will ever contain --

Copy link
Author

@SmartManoj SmartManoj Jul 15, 2025

Choose a reason for hiding this comment

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

this would cause a clash between foo:bar-baz and foo-bar:baz, right?

Theoretically yes but practically?


Can we try using -- to work around that?

Did you mean em-dash ()?

@rvolosatovs
Copy link
Member

@SmartManoj given that upstream usage has been fixed, is this still relevant?

@SmartManoj SmartManoj closed this Sep 19, 2025
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.

: is not a valid syntax for windows, wit deps cannot have name which contain : , example wasi:io

2 participants