-
Notifications
You must be signed in to change notification settings - Fork 441
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
Allow path dependencies without having everything in one Cargo workspace #1773
Comments
I think this is a duplicate (or at least has large overlap) with #1525. |
This is a large issue for my team. We have a few binaries in our repo that we cannot bring into Bazel because of this. Looking at this more, the issue is that we have:
There should be no target that actually ends up with both I tried to specify The only remaining solution I see is to vendor our crates and have a single version of As I said, this is a serious issue for my team, so I'd at least like some idea of which direction to go in, or potential alternatives. Thanks. |
So I figured out a workaround (that I've used in variant with cargo-raze in the past which has similar limitations): symlinking the crates, so that they are present in multiple places in the directory tree. I've built an example repository here: https://github.com/hobofan/rules_rust_multiple_workspaces - I'll see that I can describe it in more detail in the coming days after trying out that approach more in depth. There are some downsides with that approach (but it seems to be enough for our team at least to make the switch), so first-class support would still be great. Some limitations (I'm sure there are some I've yet to encounter):
|
I was able to get my package compiling with I'm not sure what the best way to resolve the core problem is. It's reasonable to require |
I encountered the same core issue in my monorepo, which includes multiple Cargo workspaces with path dependencies between different workspace crates. The symlink that @hobofan provided worked in my test project, but for the actual monorepo that I have, it would be very difficult to manage. I just wanted to ask about your recent findings. Have you found any better solutions for this problem? |
This is something we think would be good but haven't had time to really think about and implement. My primary concern with the feature is that folks start using path dependencies as a way to inject dependencies external to the current Bazel workspace. So Ideally relative paths leading beyond If someone were to open a PR showing these things were covered in addition to the working feature then I'd be happy to review 😄 |
Since using external dependencies is handled with |
So we've used a variation of the symlink based approach I described in an earlier comment for more than half a year at the company I worked at until it went bankrupt. I still have access and rights to use the code, so I'll try to distill the "sugar" we built around that approach before I forget how it worked 😅. The At the end we had used the approach with 10 different crate indices (I've truncated it to two in the examples below). It worked quite decently for reducing the blast radius of dependency updates between different parts of the monorepo and resolving some walls that we hit with dependency resolution in building for different targets (Linux, macOS and WASM), but also had the downside that some compile-heavy deep dependencies (in our case the patched version of RocksDB that came with Rough Cargo.toml and symlink structure
In the
Here,
|
@illicitonion was this issue also fixed by #3025? |
Yes, I believe this should have been fixed as of #3030 |
My team has a monorepo for our Rust + Go + JS project. We're trying to get all of our rust code compiling in Bazel. We have path dependencies for our own code inside the monorepo.
AFAICT this function
rules_rust/crate_universe/src/splicing/splicer.rs
Line 566 in 52e02c2
Cargo can't find compatible versions of dependencies, and I'm not aware of a way to resolve that. It's possible that specifying versions in the WORKSPACE file could work, or vendoring the dependencies. But I'd prefer not to do either of those options.
If we remove the root
[workspace]
, normal Cargo builds everything fine (path dependencies included). So it seems that the requirement of a Cargo workspace when using path dependencies is unnecessary and would be the most effective way to resolve our issue.Does this sound reasonable? Is there a better way to resolve our situation?
The text was updated successfully, but these errors were encountered: