Skip to content

Introduce a way to check for presence of a particular component and target #3007

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

Closed
chrysn opened this issue Jun 13, 2022 · 2 comments
Closed

Comments

@chrysn
Copy link

chrysn commented Jun 13, 2022

Problem you are trying to solve

I'm using rustup installed components as part of an embedded operating system's build system; the people using this may be developing Rust modules or may not even notice that they're pulling in Rust dependencies (well we're not there right now, but it might happen). The builds can have a wide range of targets (I currently have 8 targets installed), and work on different toolchains (some nightly, some stable).

Currently, I'm asserting that everything relevant is installed, and relying on error messages to guide the user -- but apart from current issues these will always be geared toward the Rust user, and not towards RIOT users.

Thus, I'd like to check whether the currently selected combination of toolchain and target is present -- LBYL makes sense over EAFTP here because I'd have to modify the way "forgiving" is asked.

Solution you'd like

Some command of rustup (it might also be cargo, really -- rustup is just my first guess) should have a way to specify a combination of toolchain and targets, and have a return code that can be processed.

This might take the shape of an --offline flag to rustup {toolchain,target} add (making it succeed only if there is nothing to do), extra arguments to cargo check (which has the upside of telling the user that things are there but they might still want to update, but the downside that for use in CI I'd still want an --offline flag so things don't fail if Rust servers are briefly off), or an extra target argument rustup +${TOOLCHAIN} show --target ${TARGET} (which would limit the output to whatever is selected, and would need to start returning an unsuccessful exit code if the selected toolchain or target is not present).

Notes

An alternative that is being considered is "just do it", which would run rustup toolchain add ${TOOLCHAIN} / rustup target add --toolchain ${TOOLCHAIN} ${TARGET} before every build. Being good citizens in the users' home directory this is not a desirable behavior: we'd use space on the user's system without them having authorized it and without a way to garbage-collect it later. (Things might be different if there were a way to add a toolchain / target "weakly" so that it'd be around for the time being and removed by rustup if not used for some time -- but unless that's planned for other reasons, it'd be excessive here).

@rbtcollins
Copy link
Contributor

I think toolchain list plus component list or something like that should meet your needs already.

@chrysn
Copy link
Author

chrysn commented Jun 16, 2022

I did miss rustup component list; with --toolchain and --installed it is machine processable enough that grepping would give me sane results. (I looked at rustup show to look for installed targets, and that's not really machine readable).

Thanks, I think that's a good enough answer to alleviate the need for further tooling.

@chrysn chrysn closed this as completed Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants