rustation / pre-commit

Reads precommit metadata from Cargo.toml and executes on commit
5 stars 2 forks source link

Breaks with a custom CARGO_TARGET_DIR #2

Open jyn514 opened 4 years ago

jyn514 commented 4 years ago

https://doc.rust-lang.org/cargo/commands/cargo-build.html#cargo_build_output_options

$ cargo check --tests
   Compiling pre-commit v0.5.2
   Compiling html5ever v0.21.0
    Checking tinytemplate v1.0.2
error: failed to run custom build command for `pre-commit v0.5.2`

Caused by:
  process didn't exit successfully: `/home/joshua/.local/lib/cargo/target/debug/build/pre-commit-24ebd6597bab580a/build-script-build` (exit code: 101)
--- stdout
looking for root in "/home/joshua/.local/lib/cargo/target/debug/build/pre-commit-eaddad5f5daa2297/out"
looking for root in "/home/joshua/.local/lib/cargo/target/debug/build/pre-commit-eaddad5f5daa2297"
looking for root in "/home/joshua/.local/lib/cargo/target/debug/build"
looking for root in "/home/joshua/.local/lib/cargo/target/debug"
looking for root in "/home/joshua/.local/lib/cargo/target"
looking for root in "/home/joshua/.local/lib/cargo"
looking for root in "/home/joshua/.local/lib"
looking for root in "/home/joshua/.local"
looking for root in "/home/joshua"
looking for root in "/home"
looking for root in "/"

--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: NotFound, error: "Crate root not found" }', /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/pre-commit-0.5.2/build.rs:9:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is the same reason docs.rs builds are failing: https://docs.rs/crate/pre-commit/0.5.2/builds/102411

jyn514 commented 4 years ago

This should probably use CARGO_MANIFEST_DIR instead of std::process::current_exe().