Search code examples
bazel

name 'package_name' is not defined (did you mean 'PACKAGE_NAME'?)


I'm using bazel 0.24.0 to build an existing bzazel project. After reading the bazel document , I change "PACKAGE_NAME" to "package_name()". The following problem shows

"name 'package_name' is not defined (did you mean 'PACKAGE_NAME'?)" .

Also , "PACKAGE_NAME" is not working by showing the errors: The value 'PACKAGE_NAME' has been removed in favor of 'package_name()', please use the latter (https://docs.bazel.build/versions/master/skylark/lib/native.html#package_name).

Aare there any solution?


Solution

  • You must use native.package_name(), not package_name.

    Also note that the documentation is versioned. You are looking at the master version, but I think you want the 0.24.0 docs: https://docs.bazel.build/versions/0.24.0/skylark/lib/native.html#package_name