ndk icon indicating copy to clipboard operation
ndk copied to clipboard

cargo apk check --workspace should work

Open dvc94ch opened this issue 4 years ago • 5 comments

I get a Didn't find Cargo.toml error in cargo-subcommand, so it's not really a bug in cargo-apk. However since cargo-apk is the only user it might make sense to move it into this repo?

dvc94ch avatar Sep 24 '21 10:09 dvc94ch

https://github.com/rust-windowing/android-ndk-rs/issues/74#issuecomment-923211056

Either way this issue should be retitled to introduce glob support in the first place and not so much about --help. That's a very real but different problem. (For example, currently running any apk command that should trigger the help prints Error: Didn't find Cargo.toml. if not in exactly the right directory or with the right arguments)

I thought it was simple to solve, but it's not really. We use subcommand to unpack the command line arguments, but before we can even figure out that someone passed no args, wrong args, or -h (either of which should trigger the help) cargo-subcommand already tries to find a workspace/package which is fallible.

The only way to solve this is to properly split out subcommand argument parsing from actually walking the project folder structure, depending on the resulting arguments.

EDIT: Yes this issue is not related to --help but I do think we have to do a lot better here. If not found we should print where we were looking for these files and what was mismatching.

MarijnS95 avatar Sep 24 '21 11:09 MarijnS95

@dvc94ch Since I don't fully understand your report and haven't heard if my comment above matches your findings, I filed #217 for it. Can you update the title and commit to better explain if you're seeing breakage specific to --workspace, and what crate layout was under $PWD?

MarijnS95 avatar Jan 24 '22 08:01 MarijnS95

I think the issue is that cargo-subcommand expects to be called inside a package, which is used to determine the package it's operating on. However in this case we are selecting all packages in the workspace.

dvc94ch avatar Jan 24 '22 13:01 dvc94ch

So that's somehow related. #217 is specifically for calling cargo apk help or version in a directory that's not necessarily a workspace or has anything rust/cargo related at all. In both cases cargo-subcommand should probably parse the args in an "infallible" way (unless the arguments are invalid), give us some information, and as a subsequent pass scan for crates, workspace roots, etc.

MarijnS95 avatar Jan 24 '22 14:01 MarijnS95

For example calling cargo apk in the root of this repo shows the same error - have to explicitly select a crate using -p (and something to do, ie. check or build).

MarijnS95 avatar Jan 24 '22 14:01 MarijnS95