rust-mobile / cargo-subcommand

Library for implementing cargo subcommands
6 stars 6 forks source link

subcommand: Do not canonicalize `target/` path that may not exist #5

Closed MarijnS95 closed 3 years ago

MarijnS95 commented 3 years ago

Canonicalization requires the path to exist such that the OS can resolve symlinks. The target/ folder doesn't exist in a clean build environment (ie. after cloning or running cargo clean), causing the unwrap to panic.

The same logic is applied to paths coming from --target-dir which may or may not be relative. Paths from find_workspace (based on those from find_package) are already canonicalized, however.

Tested normal cargo apk invocation with and without target/ dir, and CARGO_TARGET_DIR with relative and absolute path.

Fixes: bec3883 ("subcommand: Listen to CARGO(BUILD)TARGET_DIR over cwd (#4)")

MarijnS95 commented 3 years ago

@dvc94ch It doesn't seem like there's an easy to_absolute function in std covering this logic, prepending current_dir if absolute, but without canonicalization?

MarijnS95 commented 3 years ago

@dvc94ch Thanks! Can you yank 0.4.8 and make a re-release with this fixup?

dvc94ch commented 3 years ago

I don't think it has to be yanked, I published as 0.4.10.