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

Error: src/examples/README.md/Cargo.toml: Not a directory #29

Open
parasyte opened this issue Oct 28, 2024 · 5 comments · May be fixed by #30
Open

Error: src/examples/README.md/Cargo.toml: Not a directory #29

parasyte opened this issue Oct 28, 2024 · 5 comments · May be fixed by #30

Comments

@parasyte
Copy link

When parsing workspace.members, the result of glob matching doesn't filter directories. It will gladly append Cargo.toml to file paths like README.md:

for member in &workspace.members {
for manifest_dir in glob::glob(workspace_root.join(member).to_str().unwrap())? {
let manifest_dir = manifest_dir?;
let manifest_path = manifest_dir.join("Cargo.toml");
let manifest = Manifest::parse_from_toml(&manifest_path)?;

Assumes a manifest being parsed contains:

[workspace]
members = [
    "examples/*",
    "tests/*",
]

... and these directories contain a README.md or other files as direct children. An example repo in the wild where this is done:

This kind of setup causes Subcommand::new() to return an error here:

utils::find_package_manifest_in_workspace(
workspace_manifest,
potential_manifest,
package,
)?

The glob result needs to be filtered to match directories. Checking manifest_dir.is_dir() is a good start, but symlinks also need to be followed.

@MarijnS95
Copy link
Member

Looks like xbuild suffers the same issue too: rust-mobile/xbuild#183 / rust-mobile/xbuild#184

@MarijnS95
Copy link
Member

A few weird observations:

  • Cargo allows non-directories, i.e. a README.md, to be an explicit part of the members een if it is not part of a glob match);
  • Cargo only errors out if the members (be it with or without globs) results in zero matches. Even if the only match is a file, it succeeds.
    For example, if your tests/* directory only contains a README.md but no crates, it's still okay with that...

but symlinks also need to be followed.

Sounds like we should canonicalize for this, unfortunately.

@parasyte
Copy link
Author

FYI, I did the quick and dirty is_dir() hack in a private branch to unblock my work on Android builds in egui.

@MarijnS95
Copy link
Member

@parasyte thanks, but notice that a PR has already been opened and linked above. Would you mind testing it out instead?

@parasyte
Copy link
Author

I saw, and it looks good. I will test it when I get around to Android stuff again. Thanks!

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 a pull request may close this issue.

2 participants