alexcrichton / cargo-vendor

Archived as subcommand is now part of Cargo itself
Apache License 2.0
261 stars 30 forks source link

cargo install doesn't appear to respect .cargo/config #262

Closed nipunn1313 closed 5 years ago

nipunn1313 commented 5 years ago

Seems slightly related to #62 - was looking into vendoring binaries recently After running cargo vendor and updating the .cargo/config, I found that cargo build respects the config but cargo install --path . does not.

nipunn-mbp:cargo-vendor nipunn$ CARGO_HOME="" rustup run nightly cargo build --verbose
   Compiling proc-macro2 v0.4.27
     Running `rustc --crate-name build_script_build /Users/nipunn/src/cargo-vendor/vendor/proc-macro2-0.4.27/build.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=4e559f29eeacd560 -C extra-filename=-4e559f29eeacd560 --out-dir /Users/nipunn/src/cargo-vendor/target/debug/build/proc-macro2-4e559f29eeacd560 -L dependency=/Users/nipunn/src/cargo-vendor/target/debug/deps --cap-lints allow`

vs

nipunn-mbp:cargo-vendor nipunn$ CARGO_HOME="" rustup run nightly cargo install --path . --verbose --force
  Installing cargo-vendor v0.1.23 (/Users/nipunn/src/cargo-vendor)
   Compiling proc-macro2 v0.4.27
     Running `rustc --crate-name build_script_build /Users/nipunn/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.4.27/build.rs --color always --crate-type bin --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=07d78daede35e699 -C extra-filename=-07d78daede35e699 --out-dir /Users/nipunn/src/cargo-vendor/target/release/build/proc-macro2-07d78daede35e699 -L dependency=/Users/nipunn/src/cargo-vendor/target/release/deps --cap-lints allow`

as a result, if we want to use a cargo installed binary, we have to do cargo build --release followed by copying the binary target over from target/release/{name} to a bin/ directory

According to comments on #62 - this is not how it used to work - though I don't remember exactly.

nipunn1313 commented 5 years ago

To repro the above example

https://github.com/alexcrichton/cargo-vendor
cd cargo-vendor
cargo vendor -x
# Update .cargo/config as requested

then compare these two

cargo build --verbose
cargo install --path . --verbose
alexcrichton commented 5 years ago

I think this may have recently been fixed in https://github.com/rust-lang/cargo/pull/6804, can you try the latest nightly Cargo and see if it fixes the issue? (I think that change should have made its way to nightly by now)

alexcrichton commented 5 years ago

This crate is now included natively in Cargo as of https://github.com/rust-lang/cargo/pull/6869 and today's nightly Rust. I'm closing all issues in this repository before I archive the repository, but if you're still interested in seeing this issue fixed then please feel free to file an issue with Cargo itself!