Building from current `main` branch fails
While poking around and following the install instructions:
rustup install nightly-2025-08-01
cargo +nightly-2025-08-01 install --git https://github.com/facebook/buck2.git buck2
I encountered the following error:
Compiling buck2_cmd_completion_client v0.1.0 (/Users/theo/.cargo/git/checkouts/buck2-d175d02358baf776/c89c58f/app/buck2_cmd_completion_client)
error[E0599]: no method named `blocking_queue_depth` found for struct `RuntimeMetrics` in the current scope
--> app/buck2_server/src/snapshot.rs:74:55
|
74 | snapshot.tokio_blocking_queue_depth = metrics.blocking_queue_depth() as u64;
| ^^^^^^^^^^^^^^^^^^^^
|
help: there is a method `global_queue_depth` with a similar name
|
74 - snapshot.tokio_blocking_queue_depth = metrics.blocking_queue_depth() as u64;
74 + snapshot.tokio_blocking_queue_depth = metrics.global_queue_depth() as u64;
|
error[E0599]: no method named `num_idle_blocking_threads` found for struct `RuntimeMetrics` in the current scope
--> app/buck2_server/src/snapshot.rs:75:60
|
75 | snapshot.tokio_num_idle_blocking_threads = metrics.num_idle_blocking_threads() as u64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `RuntimeMetrics`
error[E0599]: no method named `num_blocking_threads` found for struct `RuntimeMetrics` in the current scope
--> app/buck2_server/src/snapshot.rs:76:55
|
76 | snapshot.tokio_num_blocking_threads = metrics.num_blocking_threads() as u64;
| ^^^^^^^^^^^^^^^^^^^^ method not found in `RuntimeMetrics`
Compiling buck2_cmd_debug_client v0.1.0 (/Users/theo/.cargo/git/checkouts/buck2-d175d02358baf776/c89c58f/app/buck2_cmd_debug_client)
For more information about this error, try `rustc --explain E0599`.
error: could not compile `buck2_server` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `buck2 v0.1.0 (https://github.com/facebook/buck2.git#c89c58f8)`, intermediate artifacts can be found at `/var/folders/zh/jqg80dw961j_k5634kv_qhd00000gn/T/cargo-installvV93bz`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Didn't dig into the why too much, but choosing a commit before these calls were added leads to a successful build:
cargo +nightly-2025-08-01 install --git https://github.com/facebook/buck2.git --rev c6bfcc629378a00921aa04597551442c9e2ea2eb buck2
...
Finished `release` profile [optimized] target(s) in 3m 06s
Installing /Users/theo/.cargo/bin/buck2
Installed package `buck2 v0.1.0 (https://github.com/facebook/buck2.git?rev=c6bfcc629378a00921aa04597551442c9e2ea2eb#c6bfcc62)` (executable `buck2`)
Can confirm the same error.
Maybe Buck2's executable installation should be based on fixed version releases to crates.io
It's the instructions that should change, not the release process. It seems to recommend building from the tip of a megamonorepo, which is a bad idea. Their CI cannot be expected to slow down just to run GitHub Actions and cargo check. So it will very often contain breakage for the OSS build. Also, buck's binaries will not be published on crates.io because it's something like 75 separate crates and there is not a single API among them that should appear to be public or be depended on by anyone.
The binaries on the releases page are proof enough that something builds. The docs should recommend building from a release tag like latest, which cargo install can do.
Same error persists until this day
With "--cfg tokio_unstable -C strip=debuginfo" it builds fine. These flags are how they build it in https://github.com/facebook/buck2/blob/cb025dbd7091e8fc997818d56f98a8216b6c4969/.github/workflows/upload_buck2.yml#L125
Thanks @Overhatted , tokio_unstable was the missing piece.
This command worked for me:
RUSTFLAGS="--cfg tokio_unstable" cargo +nightly-2026-02-28 install --git https://github.com/facebook/buck2.git --rev a08f118f8fa0e8e84a829c067f4fe93e671ac959 --locked buck2
80% sure this is fixed by https://github.com/facebook/buck2/commit/b6605b3480e53b882161ec9ae17f5aa1b4458ef1, so I'm going to close for now. Let me know if this recurs, though.
That doesn't seem to fix the issue. "cargo install --git ..." ignores the .cargo/config.toml in the repository. There are lots of similar issues related to this on Github: https://github.com/rust-lang/cargo/issues/14001
I think the only fix is to update the documentation to tell users to run $env:RUSTFLAGS="--cfg tokio_unstable -C strip=debuginfo -C codegen-units=1" before the cargo install command.
Also, apparently there are long term plans to support this use case: https://github.com/rust-lang/cargo/issues/12738
Oh that's annoying, I can't fix the issue title to say "cargo install instructions are broken". GitHub moment :( Anyway, makes sense, and a pr to fix this would likely be merged promptly in the current environment if you'd like to fix it.
I would merge a PR to fix the build instructions - at least until cargo supports what we need