Search code examples
bazelbzlmod

Use Bzlmod with registry on local file system?


Is it possible to use a Bazel registry with bzlmod that lives on the local filesytem, e.g.:

bazel build --enable_bzlmod --registry="file://Users/me/bazel-central-registry" -- //...

I downloaded an archive of https://github.com/bazelbuild/bazel-central-registry and extracted it on my filesystem. When I run the above command pointing at the location where the extracted archive resides I get:

Error computing the main repository mapping: Error accessing registry file://Users/me/bazel-central-registry: Users


Solution

  • Use three slashes i.e.

    bazel build --enable_bzlmod --registry="file:///Users/me/bazel-central-registry" -- //...
    

    Alternatively if you want to have the registry stored within your repository you can use --registry="file://%workspace%/registry in order to use a registry stored in a directory called registry at the root of your workspace.