Skip to content

expand wildcards in workspace member paths #392

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

Closed
wants to merge 2 commits into from

Conversation

hallettj
Copy link

@hallettj hallettj commented Mar 8, 2025

This fixes a problem that comes up when referencing a dependency via git where the dependency is in a workspace, and the workspace manifest lists members using wildcards / file globs. An example is ndc-sdk-rs whose Cargo.toml defines a virtual workspace like this:

[workspace]
resolver = "2"
members = ["crates/*"]

When using crate2nix in IFD mode referencing dependencies in this workspace fails because tools.nix expects workspace members to be given as exact paths, without wildcards. You get an error of this form:

No such file or directory, crates/*

This PR adds a function to produce a list of exact paths given a path that might contain wildcards, and a directory to search in. It modifies the logic that looks up crates in a workspace in a git dependency to use the new function.

I included a number of unit tests to try to verify the functionality of glob expansion. I think an integration test would be a good idea, but that requires a dependency that can be referenced via git. The best example I know of is ndc-sdk-rs which I mentioned above. It's non-trivial so I was hesitant to add the necessary build time to the test suite in crate2nix.

@Pacman99
Copy link

I just opened a PR that I think has a simpler solution for this that also solves another problem that I describe in that PR: #394

@hallettj
Copy link
Author

I just opened a PR that I think has a simpler solution for this that also solves another problem that I describe in that PR: #394

Oh yes, I see how avoiding implementing file path wildcards in Nix is simpler! I notice that #394 ignores the workspace.members property of the workspace manifest, and instead gathers all Cargo.toml files in the source tree. My first thought was that might cause problems with projects with example or test crates that aren't intended to be distributed. But then I saw this comment which seems to indicate that maybe #394 is a better match to Cargo's behavior than either this PR, or the preexisting behavior: rust-lang/cargo#1462 (comment)

@hallettj
Copy link
Author

Closing in favor of #394

@hallettj hallettj closed this Mar 16, 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.

2 participants