Bear is a free, open source build & deployment project written in Rust and released under GPL-3.0. It has 6,486 GitHub stars, 369 forks and 0 open issues, and was last pushed 13 days ago. On this registry it ranks #23 of 59 tracked projects in Build & Deployment, with 5 head-to-head comparisons available. It gained 4 stars over the last 3 tracked days.

What is Bear?

Bear is a GPL-3.0, Rust-based command-line tool that produces a compile_commands.json compilation database for any C or C++ build by recording the compiler invocations that run during it, and it is aimed at developers, code explorers, and CI jobs whose build systems cannot emit that database on their own.

What it is

Bear lives in the C and C++ tooling ecosystem, in the space around Clang tooling and the JSON compilation database format that LLVM defines. That file describes how each translation unit is compiled, and editors, language servers, and analyzers such as clangd and clang-tidy depend on it to provide code navigation, autocomplete, and diagnostics. Bear generates that file by observing a build as it executes, capturing the exact compiler invocations, including flags injected by wrappers and entries for generated sources.

The concrete problem it solves is the manual effort of producing a compilation database by hand. Many build systems cannot export one, leaving developers to either modify the build or maintain the database manually, which drifts from reality as soon as flags or source files change. Bear replaces that work with a single command prefix, and the README states plainly that no changes to the build system are required. When the build cannot be run at all, it can instead interpret the commands a build system plans to run and format them as though they had executed.

Key capabilities

  • Prefixes any build command: bear -- captures compiler invocations while the build runs and writes compile_commands.json into the current working directory.
  • Reconstructs a database without running a build, from dry-run output or a saved log: make -n | bear parse-sh.
  • Separates Bear's own options from the build command, treating everything after -- as part of the build command itself.
  • Handles wrapper and launcher toolchains, including ccache, distcc, and icecc.
  • Covers unusual toolchains named in the README: embedded (ARM, TI, Microchip, QNX), HPC (Cray, Intel, NVIDIA, MPI wrappers), CUDA, and cross-compilers.
  • Runs on Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, and DragonFly BSD.
  • Documents limitations, known issues, and platform-specific usage on a documentation site, with bear --help and a man page for local reference.

Who uses it and how

  • Teams building with Make, autotools, or custom scripts, which the README describes as most of the C world, who want clangd working without touching the build.
  • Developers exploring a third-party project or a codebase they cannot modify, who need tooling support before any build-system change is possible.
  • CI jobs that need a compilation database without altering the build definition.
  • Engineers on embedded, HPC, and CUDA toolchains, where compilers are wrapped or cross-targeted and standard export paths do not exist.
  • Anyone holding only a CI log or dry-run output, who reconstructs the database from that text rather than re-running the build.

Getting started

Bear is packaged for many distributions, so check the distribution's package manager first, as the README advises; a Repology badge tracks packaging status. Alternatively, build it from source following INSTALL.md. After installation, prefix the build with bear --.

How it compares

CMake, Meson, and Bazel can each export a compilation database directly, and the README says to use that route when it is available. Bear is the tool of choice when the build system cannot do so, covering Make, autotools, custom scripts, unmodifiable third-party builds, and unusual toolchains. It is a general-purpose interception layer rather than a build-system feature, which is why it works across builds that never implemented an export.

When to use it — and when not to

Bear is a local command-line tool rather than a hosted service, so a self-hoster operates no database, object storage, or mail infrastructure; the real cost is running the build in an environment where the compiler is actually invoked. Projects already on CMake, Meson, or Bazel should use the built-in export instead of adding Bear to the workflow. The chief caution is that each operating system and build system constrains how Bear can run and which interception method is available, and the README warns that those constraints affect the final output, with the documentation site covering the details. Adoption is substantial at 6,486 stars and 369 forks, and the project is licensed under GPL-3.0.

project readme (upstream, from github) — read inline

Packaging status GitHub release GitHub Release Date Continuous Integration Contributors

ʕ·ᴥ·ʔ Build EAR

Bear gives you working code navigation, autocomplete, and diagnostics on any C/C++ project, whatever the build system. Prefix your build command with bear -- and it produces the compile_commands.json file that Clang tooling (clangd, clang-tidy, and friends) needs to understand your code.

The JSON compilation database describes how each translation unit is compiled. Bear captures the compiler invocations while your build runs and writes the database for you - no changes to your build system required.

When to use Bear

Bear is the tool of choice when the build system cannot produce a compilation database for you:

  • Make, autotools, or custom script builds - most of the C world.
  • A build you cannot or do not want to modify: a third-party project, a codebase you are just exploring, a CI job.
  • Unusual toolchains: embedded (ARM, TI, Microchip, QNX), HPC (Cray, Intel, NVIDIA, MPI wrappers), CUDA, cross-compilers, and compiler launchers such as ccache, distcc, and icecc.
  • A build you cannot run at all: parse make -n dry-run output or a saved build log instead.

Bear can intercept the build as it runs, recording what the compiler was actually invoked with, including flags injected by wrappers and entries for generated sources. Bear can also interpret the commands a build system plans to run, formatting those into a compilation database as if they had executed.

If your project uses CMake, Meson, or Bazel, those tools can export a compilation database directly; use that when it is available.

How to install

Bear is packaged for many distributions. Check your distribution's package manager first. Alternatively, you can build it from source.

How to use

After installation, run:

bear -- 

Bear writes compile_commands.json to the current working directory. Pass Bear's own options before --; everything after that is treated as part of the build command.

If you cannot run the build - all you have is a CI log or the build system's dry-run output - Bear can reconstruct the database from that text instead:

make -n | bear parse-sh

For more, run bear --help or read the man page. The documentation site covers limitations, known issues, and platform- and toolchain-specific usage.

Limitations

Bear works on Linux, macOS, FreeBSD, OpenBSD, NetBSD, DragonFly BSD, and Windows.

Each operating system and build system imposes constraints on how Bear can run and which interception method is available, and those affect the final output. The documentation site describes the available options and each option's limitations.

Acknowledgments

Bear is kept going by people who chip in. Thank you.

  • @maflcko for regular sponsorship.
  • Anthropic for a free Claude subscription, which supported development work.

Problem reports

Before opening a new problem report, please check the documentation to see if your problem is a known issue with a documented workaround. It's also helpful to look at older (possibly closed) issues before opening a new one.

If you decide to report a problem, please provide as much context as possible to help reproduce the error. If you just have a question about usage, please don't be shy; ask your question in an issue or in our chat.

If you've found a bug and have a fix for it, please share it by opening a pull request.

Please follow the contribution guide when you do.

Frequently asked questions

Is Bear free to use?

Bear is open source under the GPL-3.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does Bear do?

Generate compile_commands.json for any C or C++ build

What is Bear written in?

Bear is primarily written in Rust. Its source is publicly available at https://github.com/rizsotto/Bear, and it has 6,486 GitHub stars.