facebook / buck2

Build system, successor to Buck
https://buck2.build/
Apache License 2.0
3.59k stars 224 forks source link

MacOS buck2 helloworld fails with strange errors in prelude #416

Open naveace opened 1 year ago

naveace commented 1 year ago

I am very new to Buck/Buck 2 and have limited C++ knowledge so apologies if there is an obvious step I am missing.

I have been following the Buck2 Getting Started to setup a buck2 environment. I am using a fresh conda environment on MacOS Ventura 13.5.1. clang is on my path and seems to work otherwise and I installed lld in my conda environment. All the steps up to buck2 build //... work, but that last step fails with this cryptic error:

└─[$]> buck2 build //...                                                                                                                                         <<<
From load at implicit location

Caused by:
    0: From load at prelude/prelude.bzl:8
    1: From load at prelude/native.bzl:16
    2: From load at prelude/apple/apple_macro_layer.bzl:10
    3: From load at prelude/apple/apple_rules_impl_utility.bzl:9
    4: From load at prelude/apple/apple_bundle_types.bzl:8
    5: Error parsing: `prelude//apple/debug.bzl`
    6: error: `AppleDebuggableInfo.type` is not allowed in type expression, use `AppleDebuggableInfo` instead
         --> prelude/apple/debug.bzl:41:71
          |
       41 | def get_aggregated_debug_info(ctx: AnalysisContext, debug_infos: list[AppleDebuggableInfo.type]) -> AggregatedAppleDebugInfo.type:
          |                                                                       ^^^^^^^^^^^^^^^^^^^
          |

Build ID: 68d3eaf5-d41e-4771-8ddc-e80cba51ede7
Jobs completed: 3. Time elapsed: 0.0s.
BUILD FAILED

googling has unfortunately not helped and I cannot find a way to make this work. Does anyone have reccomendations for how i can get this to build?

Also in generally the Buck2 documentation seems a bit sparse for beginners. Are there better recommended starting places to help begin to build projects? Thank you so much for your help!

thoughtpolice commented 1 year ago

The buck2 binary and buck2 prelude are currently fairly tightly woven together. Your error is a result of the two being incompatible (in particular there has recently been a long migration from the "old" way of specifying Starlark types to the new form that is more compatible with upstream Python, which is what you're seeing here.)

What probably happened is that you downloaded a copy of buck2's binary, but used an incompatible version of the Prelude. (For example, you downloaded the release from 9-15-2023, but are using the latest Prelude from Git.) If you download the latest tag from the releases page (or compile from Git), and run that with an up-to-date Prelude, do things work better?

See also: https://github.com/facebook/buck2/issues/384

rkferreira commented 1 year ago

Works fine on my mac installing buck2 from scratch as following quick start steps.

localhost:hello_world rkferreira$ buck2 build //...
Build ID: 8fb2446b-d47c-4e3f-8e0a-37d75e67156d
Jobs completed: 63. Time elapsed: 3.4s.
Cache hits: 0%. Commands: 6 (cached: 0, remote: 0, local: 6)
BUILD SUCCEEDED

localhost:hello_world rkferreira$ buck2 run //:main
Build ID: 4c5aa344-982b-4310-8ee7-20d48c5d764f
Jobs completed: 3. Time elapsed: 0.0s.
BUILD SUCCEEDED
Hello from a C++ Buck2 program!
localhost:hello_world rkferreira$ pwd
/Users/rkferreira/git/buck2/examples/hello_world

localhost:hello_world rkferreira$ buck2 --version
buck2 4aed9ff50e4e30fb803624acc00e23a1 <build-id>

localhost:hello_world rkferreira$ sw_vers
ProductName:        macOS
ProductVersion:     13.5.1
BuildVersion:       22G90