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

Permit library-only and binary-only dependencies #128220

Closed
jhpratt opened this issue Jul 26, 2024 · 3 comments
Closed

Permit library-only and binary-only dependencies #128220

jhpratt opened this issue Jul 26, 2024 · 3 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.

Comments

@jhpratt
Copy link
Member

jhpratt commented Jul 26, 2024

Rust permits a package to contain both a library and a binary. However, any dependencies are necessarily shared, which is frequently undesirable. The only available alternative is to split the package in two, at which point the name (on crates.io) must be different.

My specific use case is avoiding deps like clap for anyone building a library, which adds needless overhead when building (even if only in non-incremental builds).

How feasible would it be to have [bin-dependencies] and [lib-dependencies] sections? These sections would extend the existing [dependencies] for backwards compatibility. Alternatively, a dependency could be specified with { bin = true, lib = false } or similar.

@jhpratt jhpratt added T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Jul 26, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 26, 2024
@jhpratt jhpratt removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 26, 2024
@lqd
Copy link
Member

lqd commented Jul 26, 2024

This issue should probably be moved to cargo's repository.

@Skgland
Copy link
Contributor

Skgland commented Jul 26, 2024

As the binary implicitly depends on the lib I don't think [lib-dependencies] would be necessary, as they would implicitly be transitive dependencies of the bin.
One could make the binary only dependencies optional dependencies and require a feature for the binary that enables these dependencies.

Note that there is rust-lang/cargo#1982 that is basically a dupplicate, and there was rust-lang/cargo#10409 which was closed due to significant overlap with rust-lang/cargo#4663

@jhpratt
Copy link
Member Author

jhpratt commented Jul 26, 2024

I forgot cargo was its own repo. Closing in favor of that long-standing issue.

@jhpratt jhpratt closed this as completed Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants