Skip to content

Conversation

@Silic0nS0ldier
Copy link
Contributor

This fixes an issue where repositories injected with --inject_repository can invalidate MODULE.bazel.lock by changing the order innate use_repo_rule extensions are registered.

For example;

# //:MODULE.bazel
local_repository = use_repo_rule("@//:defs.bzl", "local_repository")
local_repository(name = "repo")
bazel mod dump_repo_mapping '' --inject_repository=my_repo=%workspace%/other_repo
# Bazel 9+
# {"my_repo":"+local_repository+my_repo","repo":"+local_repository2+repo",...}
# Bazel 8
# {"my_repo":"+_repo_rules+my_repo","repo":"+_repo_rules2+repo",...}

Handling repository injections later changes how collisions with apparent repository names from innate extensions (use_repo_rule(...)(...)) and module extensions (use_extension(...).__(...)) are reported. To permit debugging (and improve collision investigation in general) the error message now refers to the incoming and existing repo name definition.

For example;

-Error in use_repo: The repo name 'my_repo' is already being used by --inject_repository at <builtin>
+ERROR: The repo name 'my_repo' cannot be defined by --inject_repository at <builtin> as it is already defined by a use_repo() call at /___/MODULE.bazel:2:9

@fmeum
Copy link
Collaborator

fmeum commented Nov 26, 2025

@bazel-io fork 9.0.0

@fmeum
Copy link
Collaborator

fmeum commented Nov 26, 2025

@bazel-io fork 8.5.0

@Silic0nS0ldier Silic0nS0ldier marked this pull request as ready for review November 26, 2025 09:19
@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Nov 26, 2025
Copy link
Member

@meteorcloudy meteorcloudy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Nov 26, 2025
@duncanlintw
Copy link

這修復了一個問題,即透過更改固有擴充的註冊順序,注入的儲存庫--inject_repository可能會失效。MODULE.bazel.lock``use_repo_rule

例如;

# //:MODULE.bazel
local_repository = use_repo_rule("@//:defs.bzl", "local_repository")
local_repository(name = "repo")
bazel mod dump_repo_mapping '' --inject_repository=my_repo=%workspace%/other_repo
# Bazel 9+
# {"my_repo":"+local_repository+my_repo","repo":"+local_repository2+repo",...}
# Bazel 8
# {"my_repo":"+_repo_rules+my_repo","repo":"+_repo_rules2+repo",...}

稍後對倉庫注入的處理方式有所改變,導致與來自固有擴展(use_repo_rule(...)(...))和模組擴展(use_extension(...).__(...))的倉庫名稱衝突的報告方式有所改變。為了方便偵錯(並改善衝突調查),錯誤訊息現在會引用傳入和已存在的倉庫名稱定義。

例如;

-Error in use_repo: The repo name 'my_repo' is already being used by --inject_repository at <builtin>
+ERROR: The repo name 'my_repo' cannot be defined by --inject_repository at <builtin> as it is already defined by a use_repo() call at /___/MODULE.bazel:2:9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants