Skip to content
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

Please can not find the yaml target. However it does exist. #3284

Closed
PeterBocan opened this issue Nov 1, 2024 · 2 comments
Closed

Please can not find the yaml target. However it does exist. #3284

PeterBocan opened this issue Nov 1, 2024 · 2 comments

Comments

@PeterBocan
Copy link
Contributor

PeterBocan commented Nov 1, 2024

Hello peeps, I am struggling to reason why the go_repo is not being correctly registered in the build graph. (Please version: 17.12.1)

go_library(
    name = "project",
    srcs = ["project.go"],
    visibility = ["PUBLIC"],
    deps = [
        "//third_party/go:yaml.v3",
    ],
)
❯ plz build //...
Build stopped after 230ms. 1 target failed:
    //pkg/project:project
Error building target //pkg/project:project: exit status 1
pkg/project/project.go, line 8, column 7: could not import gopkg.in/yaml.v3 (open : no such file or directory)

my third_party/go/BUILD is as follows:

package(default_visibility = ["PUBLIC"])

go_toolchain(
    name = "toolchain",
    version = "1.23.2",
)

go_stdlib(name = "std")

go_repo(
    name = "yaml.v3",
    module = "gopkg.in/yaml.v3",
    version = "v3.0.1",
    visibility = ["PUBLIC"],
)

go_repo(module="gopkg.in/check.v1", version="v0.0.0-20161208181325-20d25e280405")

and query alltargets says:

//plugins:go
//third_party/go:gopkg.in_check.v1
//third_party/go:std
//third_party/go:toolchain
//third_party/go:toolchain_compile
//third_party/go:toolchain_cover
//third_party/go:toolchain_link
//third_party/go:yaml.v3

It is very similar to #3084

@PeterBocan PeterBocan changed the title Please can not fin Please can not find the yaml target. However it does exist. Nov 1, 2024
@toastwaffle
Copy link
Contributor

When using go_repo, a subrepo is generated for the third party library. Your dependency should be something like "///third_party/go/gopkg.in_yaml.v3//:yaml.v3".

I recommend making use of Puku, as it will configure your dependencies for you

@Tatskaari
Copy link
Member

Tatskaari commented Nov 1, 2024

To add to what @toastwaffle said, if you prefer a UX closer to how go_module() works, you can add the packages you want to the install list and then depend on //third_party/go:yaml.v3:

go_repo(
    name = "yaml.v3",
    module = "gopkg.in/yaml.v3",
    install = ["."],
    version = "v3.0.1",
    visibility = ["PUBLIC"],
)

but puku fmt -w will update your build files automatically for you :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants