cargo-make icon indicating copy to clipboard operation
cargo-make copied to clipboard

taplo install failing because --locked isnt default for bin crates

Open jayvdb opened this issue 8 months ago • 6 comments

Describe The Bug

The format-toml task uses taplo, which is broken atm. A new release is pending with https://github.com/tamasfe/taplo/issues/473 , but that is taking a while to be finished.

However the real solution is to install bin crates using --locked. Also it is weird that the default task is using --force - if the appropriate version is already installed, why force a re-install??

The workaround atm is to add CARGO_MAKE_CRATE_INSTALLATION_LOCKED = "true" to the env section, but that should be the default for bin crates. c.f. https://stackoverflow.com/questions/76989793/why-cargo-install-needs-locked-to-work, https://doc.rust-lang.org/cargo/commands/cargo-install.html#dealing-with-the-lockfile

To Reproduce

Use "format-toml" task.

Error Stack

[cargo-make] INFO - Execute Command: "rustup" "run" "nightly" "cargo" "install" "--force" "taplo-cli"
    Updating crates.io index
  Installing taplo-cli v0.8.1
    Updating crates.io index
error: failed to compile `taplo-cli v0.8.1`, intermediate artifacts can be found at `/tmp/cargo-installf1VxJL`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Caused by:
  failed to select a version for the requirement `ahash = "^0.7.6"`
  candidate versions found which didn't match: 0.8.5, 0.8.4, 0.4.1, ...
  location searched: crates.io index
  required by package `taplo v0.12.1`
      ... which satisfies dependency `taplo = "^0.12.1"` of package `taplo-cli v0.8.1`
  perhaps a crate was updated and forgotten to be re-vendored?
[cargo-make] ERROR - Error while executing command, exit code: 101
[cargo-make] WARN - Build Failed.

Code Sample

jayvdb avatar Oct 23 '23 23:10 jayvdb

cargo-make defaults do not force the installation. it adds force only if it needs to install (due to crate not already installed or wrong version installed). so it doesn't install it again and again.

The current definition is at: https://github.com/sagiegurari/cargo-make/blob/36c93a6134ca4c795941576fdf8b7b4a2c19f9ae/src/lib/descriptor/makefiles/toml.toml#L5C1-L18C1

basically:

install_crate = { crate_name = "taplo-cli", binary = "taplo", test_arg = [
  "--help",
] }

so you can modify that definition in your makefile to define the specific version you want and that should solve it for you.

sagiegurari avatar Nov 04 '23 13:11 sagiegurari

My apology if I incorrectly concluded that --forced is being used unnecessarily.

However, this issue is about not using --locked

jayvdb avatar Nov 04 '23 13:11 jayvdb

if you add a specific version to the above definition, it will add the locked automatically and no need to define the env var. sorry if the docs that mentioned it aren't clear enough

sagiegurari avatar Nov 04 '23 13:11 sagiegurari

I would like cargo make to install the latest version, using --locked.

jayvdb avatar Nov 04 '23 18:11 jayvdb

thats something i think I can add, or you can PR that. wdyt?

sagiegurari avatar Nov 07 '23 21:11 sagiegurari

great. I can PR it.

jayvdb avatar Nov 08 '23 00:11 jayvdb