Bazel Blog

Bazel 4.0

Bazel 4.0 is a major release and Bazel’s first LTS release. It contains new features and backwards incompatible changes.

New features

Incompatible changes

The following flags have been enabled by default:

The following flag has been added:

The following flags have either been removed or are no-ops:

User Interface

  • Error messages emitted when an action fails have been reworked to be more informative about the failing action.


Build Event Protocol

  • The Build Event Protocol uses AbortReason.OUT_OF_MEMORY for abort events when the build tool is crashing due to OOM.


  • The Starlark JSON module is now available. Use json.encode(x) to encode a Starlark value because JSON. struct.to_json(x) is deprecated and will be disabled by the --incompatible_struct_has_no_methods flag.
  • Use proto.encode_text(x) to encode a Starlark value because textproto. struct.to_proto() is deprecated and will be disabled by the --incompatible_struct_has_no_methods flag. Both functions now reject list/dict fields that contain list/dict elements.


  • Support for using AndroidX dependencies in data-binding-enabled targets has been added.
  • Data-binding generation for android_local_test has been fixed.
  • Instrumented files for transitive sources of android_library and android_binary have been propagated.


  • The relative_ast_path feature for darwin builds to relativize swiftmodule paths for debugging has been added.
  • The --default_ios_provisioning_profile flag has been removed (it was a no-op).
  • debug_prefix_map_pwd_is_dot feature has been enabled by default on macOS. This feature passes -fdebug-prefix-map=$PWD=. for every compile to remove absolute paths from debug information.

Process Management / Sandboxing

  • With --experimental_worker_multiplex, Javac workers now use a single multithreaded process, saving memory.
  • Bazel returns exit code 36 (rather than 1) if it fails to start a subprocess in a local sandbox due to environmental issues, for example, if the argument list is too long.

Build Defs


  • py_binary now tolerates package paths that contain hyphens ('-'). Note that such paths might not be importable from within Python code.


  • The toolchain rule has been extended with the target_settings attribute.

Action Execution

  • The new dynamic scheduler that is more resistant to network issues is now the default.


  • A new release versioning page has ben published, covering versioning and the types of releases for Bazel users and contributors.
  • Information about creating persistent workers and multiplex workers has been curated in a Persistent Workers section for ease of reference.
  • A new Sandboxing page has been published, that covering how to use the sandboxing strategy to restrict file system access, and how to debug issues that may arise.

This release contains contributions from many people at Google, as well as Adam Liddell, Akira Baruah, Alex Eagle, Alexander Grund, Andrew Z Allen, Benjamin Peterson, Benson Muite, Brentley Jones, Cristian Hancila, Dan Halperin, Daniel Wagner-Hall, Dmitry Ivankov, Eric Cousineau, Gregor Jasny, Grzegorz Lukasik, Joe Lencioni, Jonathan Perry, Jonathon Belotti, Keith Smiley, Kevin Gessner, Matt Davis, Matt Mackay, Menny Even Danan, Neeraj Gupta, Philipp Schrader, Ricardo Delfin, Ryan Beasley, Samuel Giddins, Simon Bjorklen, Simon Stewart, Stiopa Koltsov, Thi Doan, ThomasCJY, Tom de Goede, V Vn Ngha, William A Rowe Jr, Yannic, Yannic Bonenberger, erenon, hollste, johnjbarton, vectoralpha.