Bazel

Advantages

  • Hermetic builds
  • Dependency graph
  • Local build and test cache
  • Remote cache
  • Remote execution
  • Unified API for builds, tasks, and tests

Disadvantages

  • Additional layer of abstraction and complexity
  • Weird edge cases and occasional bugs
  • Lack of support, documentation, and information on the internet
  • The majority of advantages are irrelevant for the majority of codebases

.bazelrc has variables

  • %workspace%: Workspace directory

https://bazel.build/run/bazelrc

Local registry module is cached

If you changed a local registry module, but bazel still uses the old version, restart bazel: bazel shutdown

https://github.com/bazelbuild/bazel/issues/20477#issuecomment-1851057077

Output root ownership

Bazel checks ownership of the output root at startup, so it will fail with mkdir('/path/to/dir'): (error: 13): Permission denied if the current user does not own the directory.

Example:

$ bazel --client_debug
...
[FATAL 15:19:33.457 src/main/cpp/blaze_util_posix.cc:499] mkdir('/path/to/dir'): (error: 13): Permission denied

Traceback:

js_binary does not work for some reason

One of possible errors:

FATAL: aspect_rules_js[js_binary]: RUNFILES environment variable is not set

Solutions

Run the binary (that fixes it for some reason)

bazel run //tools:postcss

Run pnpm install (sometimes node_modules directory is not up-to-date)

bazel run -- tools:pnpm --dir "${PWD}" install