Skip to content

Support for bin build-dependency #8873

Open

Description

Describe the problem you are trying to solve
I have a build.rs file using a rust cli program. For simplicity of use for other developers I would like the cli program to automatically be installed when building, but I don't want to run cargo commands to do so, as this will ignore their wishes (such as --offline or --locked).

Describe the solution you'd like
I would like to be able to install bin programs in the Cargo.toml. Suggestions:

[build-dependencies]
some_cli_program = { version = "1.0", install_binaries = true }
[build-bin-dependencies]
some_cli_program = "1.0"

Notes
There are some obvious issues here. This program will be added to the users PATH (which should not be done automatically by a simple build) and risk colliding with other programs in .cargo/bin. A nice way of solving this would be that the binary isn't installed in .cargo/bin but in <target>/build/bin and are executed by running cargo build-dep [flags] <program-name> [args...] or $CARGO_TARGET_DIR/build/bin/<program-name>. This means that the function build-dep or the inclusion of $CARGO_TARGET_DIR as input to build.rs would also have to be included in this ticket.

This could be solved by running cargo install some_cli_program --root .dependencies/ in build.rs, but this will not reuse any build progress of dependencies shared with the libraries built for the project (which in my case would be almost all of them), and it will update crates.io every time it's run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-crate-dependenciesArea: [dependencies] of any kindArea: [dependencies] of any kindC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions