nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.22k stars 42 forks source link

Passing flags to cargo #119

Closed elichai closed 4 years ago

elichai commented 4 years ago

Hi, I'm trying to pass flags to cargo when using this crate but it doesn't seem to register. i.e: cargo install-update --all -- --target x86_64-unknown-linux-gnu --verbose looks regular and doesn't pass the verbose flag to cargo

nabijaczleweli commented 4 years ago

This invocation will update all packages as well as --target, x86_64-unknown-linux-gnu, and --verbose.

cargo-update has never supported directly forwarding arbitrary cargo install options, but there's some per-package config.

That being said, I can see the value in that forwarding, especially since cargo install doesn't seem to support slurping flags from the environment.

elichai commented 4 years ago

I would really like that. I have a nice bash script that automatically changes every cargo install invocation into RUSTFLAGS+=' -Clto -Ctarget-cpu=native' command cargo install "$@" --target x86_64-unknown-linux-gnu so that the installs are with LTO and special instructions(SSE/AVX etc), but this isn't possible with cargo-update

nabijaczleweli commented 4 years ago

In this case I'd much rather take the arguments to forward like CARGO_INSTALL_OPTS='--target x86_64-unknown-linux-gnu --verbose' cargo install-update, but I'm assuming this works for you just as well?

elichai commented 4 years ago

Nope, just tried CARGO_INSTALL_OPTS='--target x86_64-unknown-linux-gnu --verbose' cargo install-update --all and the output isn't verbose

nabijaczleweli commented 4 years ago

Well, yes, I've yet to finish the patch, I was asking more from a usage standpoint, I guess

elichai commented 4 years ago

ohh yeah. that works for me. but I do think it's more idiomatic to use command --command-flag -- --inner-command-flag

nabijaczleweli commented 4 years ago

In the general case I'd agree. but we already take a [PACKAGE]... argument, for which clap handles the --, so that's kinda the more expected behaviour as this stands.

nabijaczleweli commented 4 years ago

Can you test with https://github.com/nabijaczleweli/cargo-update/commit/9d5a73dcd60136b524421343090fb87e0eaf5d94 from master?

elichai commented 4 years ago

will do

elichai commented 4 years ago
error: failed to compile `cargo-update v2.3.1 (/home/elichai2/gits/cargo-update)`, intermediate artifacts can be found at `/home/elichai2/gits/cargo-update/target`

Caused by:
  failed to resolve patches for `https://github.com/rust-lang/crates.io-index`

Caused by:
  patch for `unicode-normalization` in `https://github.com/rust-lang/crates.io-index` resolved to more than one candidate
nabijaczleweli commented 4 years ago

Yes, that's a work in progress, but you should be able to git reset --hard 9d5a73dcd60136b524421343090fb87e0eaf5d94 in the mean-time

elichai commented 4 years ago

you should do unicode-normalization = "=0.1.9" if they broke stuff. it works a lot better than patching

nabijaczleweli commented 4 years ago

That worked, thank you!

elichai commented 4 years ago

it seems to work but I have a separate problem with cargo itself anyway, I'll update my bash script to also set CARGO_INSTALL_OPTS and i'll wait for a release :)

nabijaczleweli commented 4 years ago

Released in v2.4.0!