runner icon indicating copy to clipboard operation
runner copied to clipboard

Adding crate a second time emits error but no exit code

Open jayvdb opened this issue 3 years ago • 3 comments

If the same crate is added twice, the second time there is no exit-code

runner --add flagset
error: failed to parse manifest at `/Users/john.vandenberg/.cargo/.runner/static-cache/Cargo.toml`

Caused by:
  could not parse input as TOML

Caused by:
  duplicate key: `flagset` for key `dependencies` at line 9 column 1
Error occurred - restoring Cargo.toml

It would be nicer for scripting if runner --add flagset some.rs would add flagset if it is missing, and then run some.rs.

jayvdb avatar Apr 10 '21 19:04 jayvdb

It would be nice to add support for cargo-deps used by cargo-script and rust-script

jayvdb avatar Apr 11 '21 04:04 jayvdb

I have put up 0.5.0 which now actually checks whether the crate is loaded, and any subsequent attempt to --add it is a no-op. So you can do runner --add flagset some.rs now (the fancy word is that --add is idempotent now)

Not entirely sure we have solved the general problem - where we could end up with different versions of the same crate. The logic that --add uses is seriously barbaric.

As for cargo-deps - it's an interesting idea. Maybe at a minimum can ask runner to give you the directory of its cache?

stevedonovan avatar Apr 22 '21 12:04 stevedonovan

.. where we could end up with different versions of the same crate. The logic that --add uses is seriously barbaric.

Per-script deps does sound necessary for general use, however my use case only requires one version of each crate that is used by many scripts.

As for cargo-deps - it's an interesting idea. Maybe at a minimum can ask runner to give you the directory of its cache?

I dont follow this.

cargo-deps would be to allow the script to include // cargo-deps: time="0.1.25", which would cause runner would automatically do equivalent of --add time...

My project has moved from cargo-deps to using the more powerful "inline cargo" supported by https://github.com/DanielKeep/cargo-script and derivatives, which looks like:

//! ```cargo
//! [package]
//! edition = "2018"
//! [dependencies]
//! time = "0.1.25"
//! ```

jayvdb avatar May 24 '21 22:05 jayvdb