Make manifest path absolute without resolving symlinks #808
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cargo expects the file path to be absolute. However, symbolic links are allowed. It’s thus enough to call https://doc.rust-lang.org/std/path/fn.absolute.html instead of https://doc.rust-lang.org/std/path/struct.Path.html#method.canonicalize.
We have a large workspace with various crates and are using Nix/crane to build various binaries. To avoid rebuilding all components when unrelated code of a crate was altered, we want to graft a directory with symbolic links to generated workspace members (dummies, library-only, binary-only, library-with-tests, full, …). These directories are read-only.
canonicalize,cargo cyclonedxtries to find theCargo.lockin/nix/store/instead of/build/, where the generatedCargo.tomlis located./nix/store/<hash>-source/<member>/, with a lock file in/nix/store/<hash>-source/, runningcargo cyclonedxfails because it tries to output the SBOM to e.g./nix/store/<hash>-source/<member>/….cdx.json, which is a read-only directory.This works just fine for
cargo build, etc., just not forcargo cyclonedx.If this is PR is a breaking change because resolving symbolic links is expected now, perhaps some CLI flags should be implemented:
--output-dir, see e.g.cargo tarpaulin),Cargo.lock(--lockfile-path, see e.g.cargo build),However, I doubt resolving symbolic links is expected, as this differs from the behaviour of default
cargotools. On the other side: Even with my proposed change, these CLI options might be useful.