How do I depend on Buck2 targets from another project?
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I'm having trouble depending on the `buck2` repo via external cells.
I have the following setup, informed by the [documentation](https://buck2.build/docs/users/advanced/external_cells/):
`.buckconfig`
```ini
[repositories]
root = .
prelude = prelude
toolchains = toolchains
buck2 = buck2
none = none
[repository_aliases]
config = prelude
ovr_config = prelude
fbcode = none
fbsource = none
fbcode_macros = none
buck = none
[parser]
target_platform_detector_spec = target:root//...->prelude//platforms:default
[external_cells]
prelude = bundled
buck2 = git
[external_cell_buck2]
git_origin = https://github.com/facebook/buck2
commit_hash = 681c0d24a76376c75645f6a9dd633790f5f5910e
```
(The URL and git commit hash are correct)
`BUCK`
```starlark
rust_binary(
name = "main",
srcs = ["main.rs"], # Just a hello world, nothing fancy.
deps = [
"buck2//app/buck2_test_runner:buck2_test_runner",
],
)
```
I'm getting errors when running various commands:
```
> buck2 targets buck2//...
File changed: root//4913
File changed: root//main.rs
File changed: root//main.rs~
Error resolving recursive spec `buck2///...`
Caused by:
0: Error listing dir ``
1: Error listing directory
2: read_dir(/path/to/buck2-external-cell-test/buck-out/v2/external_cells/git/681c0d24a76376c75645f6a9dd633790f5f5910e)
3: No such file or directory (os error 2)
Build ID: 896501c5-1503-4b38-bd19-22eb16de01c3
Jobs completed: 2. Time elapsed: 0.0s.
```
```
> buck2 expand-external-cell buck2
File changed: root//4913
File changed: root//BUCK
File changed: root//BUCK~
Error copying from src path `/path/to/buck2-external-cell-test/buck-out/v2/external_cells/git/681c0d24a76376c75645f6a9dd633790f5f5910e` to dest path `/path/to/buck2-external-cell-test/buck2`
Caused by:
0: symlink_metadata(/path/to/buck2-external-cell-test/buck-out/v2/external_cells/git/681c0d24a76376c75645f6a9dd633790f5f5910e)
1: No such file or directory (os error 2)
Build ID: 2e48da4b-3020-42b0-96dc-8a73c150f2ad
Jobs completed: 2. Time elapsed: 0.0s.
```
```
> buck2 build :
Build ID: 998f4c90-d5ad-47fa-9fb5-c8b72d252792
Jobs completed: 51. Time elapsed: 0.1s.
BUILD FAILED
Error running analysis for `root//:main (prelude//platforms:default#904931f735703749)`
Caused by:
0: Error in configured node dependency, dependency chain follows (-> indicates depends on, ^ indicates same configuration as previous):
root//:main (prelude//platforms:default#904931f735703749)
-> buck2//app/buck2_test_runner:buck2_test_runner (^)
1: looking up unconfigured target node `buck2//app/buck2_test_runner:buck2_test_runner`
2: Error loading targets in package `buck2//app/buck2_test_runner` for target `buck2//app/buck2_test_runner:buck2_test_runner`
3: gathering package listing for `buck2//app/buck2_test_runner`
4: Error listing dir ``
5: Error listing directory
6: read_dir(/path/to/buck2-external-cell-test/buck-out/v2/external_cells/git/681c0d24a76376c75645f6a9dd633790f5f5910e)
7: No such file or directory (os error 2)
```
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` using `buck2` using the open source build and codebase supported? The documentation only mention building it with cargo and doing a quick `buck2 targets //...` results in shim-related errors.
cc @JakobDegen since you've done (most of?) the work on external cells.
Thanks a lot !
Contributor guide
Assessment
This issue has not been assessed yet.