Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding crate a second time emits error but no exit code #7

Open
jayvdb opened this issue Apr 10, 2021 · 3 comments
Open

Adding crate a second time emits error but no exit code #7

jayvdb opened this issue Apr 10, 2021 · 3 comments

Comments

@jayvdb
Copy link

jayvdb commented Apr 10, 2021

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
Copy link
Author

jayvdb commented Apr 11, 2021

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

@stevedonovan
Copy link
Owner

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?

@jayvdb
Copy link
Author

jayvdb commented May 24, 2021

.. 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"
//! ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants