buck2
buck2 copied to clipboard
using rust-project external to facebook
I was experimenting with Buck2 on a Rust project and wasn't able to get rust-project
to generate a rust-analyzer
file reliably. You can see the output that I was originally receiving below:
rust-project develop --prefer-rustup-managed-toolchain :some-code
2023-12-13T02:03:04.561917Z INFO rust_project::cli::develop: building generated code
Error: failed to deserialize command output
Caused by:
0: command `env -u RUST_BACKTRACE -u RUST_LIB_BACKTRACE "buck2" "--isolation-dir" ".rust-analyzer" "bxl" "--oncall" "rust_devx" "-c" "client.id=rust-project" "@fbcode//mode/mac" "prelude//rust/rust-analyzer/resolve_deps.bxl:expand_and_resolve" "-c=rust.failure_filter=true" "--" "--targets" ":some-code"` (exit code: exit status: 1)
stderr:
Command failed: Error expanding argsfiles
Caused by:
0: Unable to read flag file at `/Users/fponce/buck2-test/none/mode/mac`
1: No such file or directory (os error 2)
1: EOF while parsing a value at line 1 column 0
I noticed that @fbcode//mode/mac
was being passed as an argument and was able to find it referenced in the source code. By dropping that, the command works as expected and I'm able to use my IDE with the generated rust-project.json
files successfully. I had originally tried passing in alternative values to -m
but it didn't seem to work right either.
I have no doubt that this is not the correct fix, but you can see the diff here: https://github.com/facebook/buck2/commit/91214e5fbf1e0294a5b46ef5774e743461265a02
You can also just create an empty file at mode/mac
as a workaround, if you have fbcode = root
in your .buckconfig's repository aliases. See also https://github.com/facebook/buck2/issues/402 for the other thing you need to make it work. I never fixed it because pretty soon I stopped using system_rust_toolchain and I haven't been reminded of it since.
cc @davidbarsky
ah, crap, yeah. lemme get a diff up that introduces a config file/doesn't hard code this value. my bad!
Hey @davidbarsky, was playing with rust-project and ran across the same issue. Did you get a chance to get that diff up?
Hey @davidbarsky, was playing with rust-project and ran across the same issue. Did you get a chance to get that diff up?
D'oh, sorry, it fell to the wayside. I'll get that fixed today and landed today/tomorrow.
Didn't happen yesterday, sorry folks—was pulled into meetings. Gimme a day or two.
@davidbarsky one more friendly ping? Or if you want to roughly describe what change should be made I can try to push it through.
Really, really sorry: I've honestly been working on std::stream::Stream
/rust-analyzer internals lately and haven't had the time.
Or if you want to roughly describe what change should be made I can try to push it through.
@jazzdan If you want to do this, I was thinking of defining a Config
struct and deserializing from TOML using the toml
crate crate. I was initially thinking that rust-project should look for a rust-project.toml
at in the cell/project roots, but iterating over the current working directories ancestors
is likely sufficient/preferable.