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.
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
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 (transitional only)
common --enable_workspaceHow to prevent it
- Migrate all external deps to
MODULE.bazelbefore upgrading to Bazel 8. - Pin the Bazel version in
.bazelversionso upgrades are intentional. - Run
bazel mod graphto confirm every dep is bzlmod-resolved.