Flip --enable_workspace to false
Motivation
Disabling WORKSPACE by default is the next step towards migrating the Bazel ecosystem to Bzlmod for managing external dependencies.
Benefits of Bzlmod over WORKSPACE:
- Automatic MVS-based Bazel module dependency resolution
- No need to declare transitive dependencies
- Better integration with third-party package managers with module extension
- Repo level visibility control
- Easy to inspect dependency graph with
bazel mod - Support for lockfile, vendor/offline mode
We plan to remove this flag and the entire WORKSPACE logic in Bazel 9.
For more information, check https://bazel.build/external/overview
Description
With --enable_workspace defaults to false, the WORKSPACE file is no longer needed and does not take any effect in a Bazel project.
You should expect the following breaking behaviours:
- The root of a Bazel repo is no longer marked by WORKSPACE, but by MODULE.bazel (or REPO.bazel)
- External dependencies defined in WORKSPACE are no longer effective
- Toolchains/platforms registered in WORKSPACE are no longer effective
- Bind statement (already deprecated) are no longer effective
If all your external dependencies have migrated to Bzlmod, WORSPACE and WORKSPACE.bzlmod files can be safely deleted. Otherwise, you can temporarily enable WORKSPACE via --enable_workspace=true.
Incompatible Flag
--noenable_workspace
Migration Guide
Please refer to https://bazel.build/external/migration on how to migrate from WORKSPACE to Bzlmod.
We'll continue to improve the migration guide on common issues and best practices, PRs from the community are also welcomed!
And please feel free to report issues that are blocking your migration.
In which Bazel LTS version will this incompatible change be enabled?
Bazel 8
Additional Context
No response
TODO List
- [x] Implement the incompatible change at Bazel HEAD and guard it behind a flag.
- [x] Backport the incompatible flag to the latest LTS release (Flag is available in the latest minor release of Bazel 7, default to true).
- [x] Make sure output meaningful error messages when WORKSPACE is disabled.
- [ ] Test the incompatible change with downstream projects and inform broken projects.
- [ ] https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/4009
- [x] Migrate Bazel's own test suites off WORKSPACE. (All broken tests)
- [x] Python integration tests: https://github.com/bazelbuild/bazel/pull/23034
- [x] Java integration tests: https://github.com/bazelbuild/bazel/pull/23086
- [x] Shell integration tests: https://github.com/bazelbuild/bazel/pull/23087
- [x] Java unit tests: https://github.com/bazelbuild/bazel/pull/23253
- [x] Flip the incompatible flag at Bazel HEAD.
- [ ] Fix some Bzlmod bugs discovered.
- [ ] Delete the incompatible flag and the old behavior at Bazel HEAD.