You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Bazel 8构建TensorBoard主分支时遭遇未知仓库错误

解决Bazel 8构建TensorBoard主分支时@io_bazel_rules_closure仓库无法解析的问题

问题背景

构建TensorBoard主分支时执行bazel build tensorboard,出现仓库@io_bazel_rules_closure无法解析的错误。核心原因是Bazel 8默认禁用WORKSPACE文件,强制迁移到Bzlmod,但当前TensorBoard代码仍依赖WORKSPACE中声明的外部仓库。

错误日志:

$ bazel build tensorboard
Starting local Bazel server (8.1.0) and connecting to it...
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.
WARNING: Target pattern parsing failed.
ERROR: Skipping 'tensorboard': error loading package 'tensorboard': at /tmp/tensorboard/tensorboard/defs/zipper.bzl:17:6: Unable to find package for @@[unknown repo 'io_bazel_rules_closure' requested from @@]//closure/private:defs.bzl: The repository '@@[unknown repo 'io_bazel_rules_closure' requested from @@]' could not be resolved: No repository visible as '@io_bazel_rules_closure' from main repository. Was the repository introduced in WORKSPACE? The WORKSPACE file is disabled by default in Bazel 8 (late 2024) and will be removed in Bazel 9 (late 2025), please migrate to Bzlmod. See https://bazel.build/external/migration.
ERROR: error loading package 'tensorboard': at /tmp/tensorboard/tensorboard/defs/zipper.bzl:17:6: Unable to find package for @@[unknown repo 'io_bazel_rules_closure' requested from @@]//closure/private:defs.bzl: The repository '@@[unknown repo 'io_bazel_rules_closure' requested from @@]' could not be resolved: No repository visible as '@io_bazel_rules_closure' from main repository. Was the repository introduced in WORKSPACE? The WORKSPACE file is disabled by default in Bazel 8 (late 2024) and will be removed in Bazel 9 (late 2025), please migrate to Bzlmod. See https://bazel.build/external/migration.
INFO: Elapsed time: 8.749s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

相关BUILD代码片段:

load("@npm//@bazel/typescript:index.bzl", "ts_config")

licenses(["notice"])

exports_files(["tsconfig.json"])

# Inspired from internal tsconfig generation for project like TensorBoard.
ts_config(
    name = "tsconfig-lax",
    src = "tsconfig-lax.json",
    visibility = [
        "//tensorboard:internal",
    ],
    deps = [],
)

解决方案

方案1:临时启用WORKSPACE兼容模式

如果不想立即迁移到Bzlmod,可通过命令参数重新启用WORKSPACE文件支持:

bazel build --noenable_bzlmod tensorboard

该命令会让Bazel 8退回到传统WORKSPACE模式,加载项目中已有的WORKSPACE文件拉取@io_bazel_rules_closure等依赖。

方案2:迁移到Bzlmod(长期适配)

  1. 在TensorBoard项目根目录创建MODULE.bazel文件,添加io_bazel_rules_closure的依赖声明:
    module(name = "tensorboard", version = "2.17.0")
    
    # 添加rules_closure依赖,版本号可根据实际需求调整
    bazel_dep(name = "io_bazel_rules_closure", version = "0.10.0")
    
  2. 重新执行构建命令:
    bazel build tensorboard
    
    Bzlmod会自动从Bazel Central Registry拉取io_bazel_rules_closure依赖并完成构建。

方案3:使用已适配Bzlmod的TensorBoard代码

检查TensorBoard官方仓库是否已完成Bzlmod迁移:

  • 查看仓库根目录是否存在MODULE.bazel文件
  • 关注官方的迁移PR或更新公告,确保使用的代码版本已适配Bazel 8的Bzlmod模式

内容的提问来源于stack exchange,提问作者Geremia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 05:36:16