my project depends on a crate that I needed to fork. Is there any way that I can publish my project that depends on that forked crate, without publishing the forked crate itself?
I don't want to pollute crates.io with a project specific fork. I tried things like local paths and workspaces, but none of them seem to provide a working solution.
I wished there was something like a "sub-crate" or "internal-crate", so that I could just bundle my dependencies within my crate without the need to publish the forks.
I've heard of [patch], but I thought it makes sense locally only and not when publishing a crate. I should probably try that out (is there a crates.io staging area for testing purpose?).
The desire to override a dependency or otherwise alter some dependencies can arise through a number of scenarios. Most of them, however, boil down to the ability to work with a crate before it's been published to crates.io. For example:
A crate you're working on is also used in a much larger application you're working on, and you'd like to test a bug fix to the library inside of the larger application.
An upstream crate you don't work on has a new feature or a bug fix on the master branch of its git repository which you'd like to test out.
You're about to publish a new major version of your crate, but you'd like to do integration testing across an entire project to ensure the new major version works.
You've submitted a fix to an upstream crate for a bug you found, but you'd like to immediately have your application start depending on the fixed version of the crate to avoid blocking on the bug fix getting merged.
These scenarios are currently all solved with the [patch] manifest section.
That's unfortunate.
(...although... the last bullet point does sound similar to your use case. At least, in all the ways that should affect how the feature works in cargo)
I wonder if my use case is a valid one and if it makes sense to think about possible future solutions. Or if it's just a fixed decision that all crates need to be published on crates.io at all times.
It is a fixed decision. I finally found the right keywords (rust multiple libs in package) and found a thread about having multiple libraries (i.e. crates) in one package (i.e. what you publish on crates.io). The answer is that it was a design decision, hence I don't think that will ever change.
This means that I'll publish the forked crates as <my_package>_<forked_package> (better ideas are welcome).
Edit: I think I name them <my_package>_deps_<forked_package> to make clear that it isn't some sub-crate, but just a dependency.