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

How can I use the go_deps extension to apply patches to a generated dependency? #1521

Closed
aaronmondal opened this issue May 3, 2023 · 2 comments

Comments

@aaronmondal
Copy link

What version of gazelle are you using?

Custom checkout from commit 23226de, vendored in a bazel registry.

What version of rules_go are you using?

0.39.1

What version of Bazel are you using?

6.1.2

Does this issue reproduce with the latest releases of all the above?

Yes.

What operating system and processor architecture are you using?

Gentoo x86_64

What did you do?

I need to patch a transitive cgo dependency. How can I apply a patch to "an_implicit_dependency_in_need_of_patching"? In general, how can I override the attributes of dependencies that are generated this way?

# MODULE.bazel
bazel_dep(name = "rules_go", version = "0.39.1")
bazel_dep(name = "gazelle", version = "23226de")
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

# Generates ~100 deps. I need to only patch "an_implicit_dependency_in_need_of_patching"
use_repo(
    go_deps,
    "some_primary_dependency_with_many_deps",
)

In case this is not possible yet, how can I tell gazelle to skip it when reading go.mod and use a provided bazel_dep instead?

@fmeum @tyler-french @seh

@seh
Copy link
Contributor

seh commented May 3, 2023

Perhaps the go_deps.module_override tag's "patches" field would help here, if you can specify the Go module path that leads to the creation of this "an_implicit_dependency_in_need_of_patching" Bazel repository.

@aaronmondal
Copy link
Author

Ahh that works! What a nice user experience to not have to carry around deps.bzl 🎉

# MODULE.bazel
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
go_deps.module_override(
    path = "github.com/org/project",
    patches = [
        "@myproject//patches:some_custom_patch.diff",
    ],
    patch_strip = 1,
)

@seh Thanks a lot for the help ❤️

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

2 participants