Skip to content
Latchkey

Bazel WORKSPACE Deprecated - Bzlmod Migration Errors in CI

Bazel is moving from WORKSPACE to bzlmod (MODULE.bazel). On Bazel 7 bzlmod is on by default and on Bazel 8 WORKSPACE is disabled - so repositories you still declare only in WORKSPACE stop resolving in CI after a Bazel upgrade.

What this error means

After upgrading Bazel, targets fail because external repos defined in WORKSPACE are no longer visible - "repository not found" for deps that bzlmod does not know about. The same checkout built on the older Bazel.

Bazel output
ERROR: no such package '@com_example_lib//':
  The repository '@com_example_lib' could not be resolved:
  No repository visible as '@com_example_lib' from main repository.
  (WORKSPACE is disabled; declare it in MODULE.bazel.)

Common causes

WORKSPACE disabled by default on new Bazel

Bazel 8 disables WORKSPACE loading; repos declared only there are invisible unless re-declared via bzlmod.

Partial bzlmod migration

Some deps moved to MODULE.bazel but others still live in WORKSPACE; with bzlmod on, the WORKSPACE-only ones do not resolve.

How to fix it

Migrate repos to MODULE.bazel

Re-declare external deps as bazel_dep or via a module extension instead of WORKSPACE rules.

MODULE.bazel
# MODULE.bazel
bazel_dep(name = "rules_go", version = "0.48.0")
# for non-registry archives, use http_archive via a module extension
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(name = "com_example_lib", urls = [...], sha256 = "...")

Temporarily re-enable WORKSPACE to unblock

As a bridge during migration, re-enable WORKSPACE resolution while you port deps.

.bazelrc
# .bazelrc (transitional only)
common --enable_workspace

How to prevent it

  • Migrate all external deps to MODULE.bazel before upgrading to Bazel 8.
  • Pin the Bazel version in .bazelversion so upgrades are intentional.
  • Run bazel mod graph to confirm every dep is bzlmod-resolved.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →