-
Notifications
You must be signed in to change notification settings - Fork 214
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
How do I depend on Buck2 targets from another project? #684
Comments
It works with a single file gist. This is with buck2 2024-06-15, I think. Probably the biggest difference between this and the buck2 repo is that it doesn't have a .buckconfig. That's something external cells are not supposed to support. ; .buckconfig
[cells]
root = .
gist = gist
[external_cells]
gist = git
[external_cell_gist]
git_origin = https://gist.github.com/f7ec39ae8a1003dddf61953b80e06eb3.git
commit_hash = b5cbfc06d0447c4bbadbfad1ca74639c48f19102
[project]
ignore = .git # BUCK
load("@gist//:rules.bzl", "myrule")
myrule(name = "mine") buck2 build :mine |
I think you're right, since I've been able to build the examples in https://github.com/benbrittain/oci-rules (which use external cells) just fine in the meantime. That's a bit of a shame, I guess I'll submodule the Having clearer error messages would be nice, but I'll close this for now as what I'm trying to do is unsupported. Thanks ! |
If you must build from source, I recommend building it with Nix. You can also use the buck2 that's on nixpkgs if you are fine with whatever version it happens to be. Otherwise the binaries on GH releases are fine. In short, the way to build from source is: in a nix flake, using https://crane.dev to build it (which is not the same crane as the one that does OCI stuff), using direnv to load nix when you enter the folder. I believe the buck2 repo has a flake with the build time dependencies listed, and you'll need to use the same nightly version (via oxalica/rust-overlay) as the one in buck's rust-toolchain file. Pass The main benefit of doing it this way is Nix will cache it, and direnv will switch versions for you if you swap branches. But I would only bother if you need to patch buck2. |
Also cargo-based builds of buck2 are meant to be faster because they use jemalloc. Nix+crane does build with cargo. |
Nix is not an option: I'm trying to build buck2 as a library to build a custom test runner. It needs to be built as part of a buck2-based monorepo, with our own rust toolchain, so as far as I can see, my options are:
|
FYI our long term plan for cargo version is to be good enough to compile buck2, but fully featured buck2 can be build only with buck2. Because supporting every possible non-trivial feature concurrently in cargo build and in buck2 builds is more work. (We should make buck2-built buck2 use jemalloc.) |
FYI, we plan (but without specific date) is to rewrite So in your place, for now, until TestInfo V2 is implemented, I would probably avoid implementing test runner (which is nontrivial amount of work and will stop working one day anyway), I would do this instead:
|
Hmm, that negates a lot of the upsides that we wanted to leverage, including:
Do you have a timeline for TestInfo V2? Any further information I can read about it (there is only a stub in the docs right now)? |
We understand this is a critical issue for opensource buck2, but the work was not started. CC @JakobDegen.
It is in internal docs for now. We plan to publish more such docs externally. |
Ok, thanks for the clarification! I assume that this also means that you don't have an estimate for when the work is expected to start then, right? I'm just trying to plan accordingly. |
I'm reopening this with a more accurate title after playing around with this for a few hours. tl;dr: It seems to be possible to depend on rules (and possibly also macros and plain Starlark functions) from external cells, but not targets, which makes depending on buck2 projects as libraries... challenging. I have tried several approaches to building against buck2:
The first two seem more or less equivalent, as I hit the same issues and errors with both, which look something like that:
My understanding is that no matter how I do with the cell/cell aliases configuration, transitive target dependencies will resolve the root cell to my project's root, rather than buck2's root cell. Also, this has required me setting As a sanity check, I did similar tests with https://github.com/benbrittain/oci-rules, which is significantly simpler than buck2. I got the same results: it is fine to depend on rules from an external cell, but attempting to depend on e.g. So my more precise question is now: (how) can I depend on _ Buck2 targets_ from a different project? In particular, is it possible to depend on targets from the Buck2 project (which has unconventional cells and uses reindeer for third-party dependencies)? For the record, I have also tried depending on buck2 via reindeer by taking the fixups from the buck2 repo, but the output that I got from it was incomplete (mostly calls to |
Hello, I'm having trouble depending on the
buck2
repo via external cells.I have the following setup, informed by the documentation:
.buckconfig
(The URL and git commit hash are correct)
BUCK
I'm getting errors when running various commands:
When I inspect
buck-out/v2/external_cells/git
, it is empty, so I'm not sure what to try next.Ideally, could we get a full example that shows how to use external cells?
Also, is building
buck2
usingbuck2
using the open source build and codebase supported? The documentation only mention building it with cargo and doing a quickbuck2 targets //...
results in shim-related errors.cc @JakobDegen since you've done (most of?) the work on external cells.
Thanks a lot !
The text was updated successfully, but these errors were encountered: