bazelbuild / bazelbuild/bazel

How to patch dependencies of non root module in bzlmod.

Open
#25,722 17 comments 0 reactions 0 assignees View on GitHub
P4 team-Documentation team-ExternalDeps type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Page link:

Disclaimer: I am not sure if this is a documentation issue or a limitation of bzlmod.

### Problem description (include actual vs expected text, if applicable):

Hi,
I am working on a library that is used as a module by other projects. Some parts of the library require patched dependencies (for instance rules_oci, aspect_bazel_lib).

With WORKSPACE, we were recommending our users to call `my_library_deps` early in their WORKSPACE, so that we provided them patched dependencies.

I am now moving to bzlmod and have not found a way to use patched dependencies in non root module. All options - `archive_override`, `single_version_override` etc work only in root module.

To sum up, I would like to:
1. Use patched dependency in the non root module
2. Treat it as implementation detail - do not require any changes in user's MODULE that is importing my module.

Looking forward to your suggestions

### Where do you see this issue? (include link to specific section of the page, if applicable)

_No response_

### Any other information you'd like to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by comparing the existing WORKSPACE approach using my_library_deps with bzlmod concepts such as non-root modules, MODULE files, archive_override, and single_version_override. Determine whether patched rules_oci or aspect_bazel_lib dependencies can remain an implementation detail, and document or scope the supported behavior for importing projects.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.