Search code examples
c++bazel

error "name 'new_local_repository' is not defined" in bazel


I understand that the following load is required for new_git_repository: load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")

But how do I find the load required for new_local_repository. I tried browsing the build_defs git folder but new_local_repository is not defined there so I could not guess the load.

I get the the following error - name 'new_local_repository' is not defined. How do I find the required load?


Solution

  • If you're calling new_local_repository inside a .bzl file that's loaded from the WORKSPACE file, you have to use native.new_local_repository instead. This is because new_local_repository is defined in Bazel core and not any .bzl file.