Bazel: Invalid License Error While Running bazel build

Created on 4 May 2018  Â·  36Comments  Â·  Source: bazelbuild/bazel

I am trying to compile tensorflow for Macbook, but every time when I use bazel build, I am getting same error.

When I Run this command

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

I get this error

/private/var/tmp/_bazel_cagrigider/2c548436011ab6b7308cd0cc70a91ed3/external/bazel_tools/tools/cpp/BUILD:3:1: invalid license type: 'notice'

Full Output Of Terminal

Mac OS 10.13.3

Xcode version = 9.2

Tensorflow version = 1.8

Bazel version = 0.13.0

Thanks.

bug under investigation

Most helpful comment

It is working now.

Thank you so much.

All 36 comments

It looks like this is an error with tensorflow. Did you try building another project with bazel (for example the bazel repo)?

If you can build the bazel repo without a problem, I'd recommend you open an issue against TensorFlow.

I tried bazel example projects and I got same error
I tried this examples examples

My guess is that your bazel is setup incorrectly. How did you install it? Are you sure that it is version 0.13.0?

It says version 0.13.0.

I installed Bazel on this Mac with HomeBrew
but I also installed Bazel on another Mac using binary installer. Always I
get same error.

I installed from here.
https://docs.bazel.build/versions/master/install-os-x.html

On 4 May 2018 at 18:08, Robin Nabel notifications@github.com wrote:

My guess is that your bazel is setup incorrectly. How did you install it?
Are you sure that it is version 0.13.0?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/bazel/issues/5157#issuecomment-386631089,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AbIx7GfywKl5dj8VYE1o1SBTGgo1ZyN9ks5tvG7bgaJpZM4TyJ9n
.

I uninstalled bazel with :

brew uninstall --force bazel

Then installed again with:

brew install bazel

but still I got same license error.

On 4 May 2018 at 18:12, Çağrı Gider cagrigider@gmail.com wrote:

>
>

It says version 0.13.0.

I installed Bazel on this Mac with HomeBrew
but I also installed Bazel on another Mac using binary installer. Always I
get same error.

I installed from here.https://docs.bazel.build/
versions/master/install-os-x.html

On 4 May 2018 at 18:08, Robin Nabel notifications@github.com wrote:

My guess is that your bazel is setup incorrectly. How did you install it?
Are you sure that it is version 0.13.0?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/bazelbuild/bazel/issues/5157#issuecomment-386631089,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AbIx7GfywKl5dj8VYE1o1SBTGgo1ZyN9ks5tvG7bgaJpZM4TyJ9n
.

I tried bazel example projects and I got same error
I tried this examples examples

This is odd - could you please elaborate more on the steps you took to point of this error with the examples repository?

I ran these commands

cd Documents/examples/cpp-tutorial/stage1/
bazel build //main:hello-world

then I got this error.

ERROR: /private/var/tmp/_bazel_cagrigider/4c2d107b81f30b45f844673a09f76011/external/bazel_tools/tools/cpp/BUILD:17:1: invalid license type: 'notice'
ERROR: /private/var/tmp/_bazel_cagrigider/4c2d107b81f30b45f844673a09f76011/external/bazel_tools/tools/cpp/BUILD:61:1: Target '@bazel_tools//tools/cpp:grep-includes.sh' contains an error and its package is in error and referenced by '@bazel_tools//tools/cpp:grep-includes'
ERROR: /Users/cagrigider/Documents/examples/cpp-tutorial/stage1/main/BUILD:1:1: every rule of type cc_binary implicitly depends upon the target '@bazel_tools//tools/cpp:malloc', but this target could not be found because of: Target '@bazel_tools//tools/cpp:malloc' contains an error and its package is in error
ERROR: /Users/cagrigider/Documents/examples/cpp-tutorial/stage1/main/BUILD:1:1: every rule of type cc_binary implicitly depends upon the target '@bazel_tools//tools/cpp:grep-includes', but this target could not be found because of: Target '@bazel_tools//tools/cpp:grep-includes' contains an error and its package is in error
ERROR: /Users/cagrigider/Documents/examples/cpp-tutorial/stage1/main/BUILD:1:1: every rule of type cc_binary implicitly depends upon the target '@bazel_tools//tools/cpp:stl', but this target could not be found because of: Target '@bazel_tools//tools/cpp:stl' contains an error and its package is in error
ERROR: /Users/cagrigider/Documents/examples/cpp-tutorial/stage1/main/BUILD:1:1: every rule of type cc_binary implicitly depends upon the target '@bazel_tools//tools/cpp:stl', but this target could not be found because of: Target '@bazel_tools//tools/cpp:stl' contains an error and its package is in error
ERROR: Analysis of target '//main:hello-world' failed; build aborted: Loading failed

could you please paste the contents of the file /private/var/tmp/_bazel_cagrigider/4c2d107b81f30b45f844673a09f76011/external/bazel_tools/tools/cpp/BUILD here? at least for line 17.

the error is raised in this method: https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/packages/License.java;l=200

try {
     licenseTypes.add(LicenseType.valueOf(str.toUpperCase()));
} catch (IllegalArgumentException e) {
     throw new LicenseParsingException("invalid license type: '" + str + "'")
}

Enum#valueOf threw the IllegalArgumentException, which suggests that the value of str.toUpperCase() is not in LicenseType:

  public enum LicenseType {
    BY_EXCEPTION_ONLY,
    RESTRICTED,
    RESTRICTED_IF_STATICALLY_LINKED,
    RECIPROCAL,
    NOTICE,
    PERMISSIVE,
    UNENCUMBERED,
    NONE
  }

cd /private/var/tmp/_bazel_cagrigider/4c2d107b81f30b45f844673a09f76011/external/bazel_tools/tools/cpp/

ls

Result :

output

could you please paste line 17 of the BUILD file in that directory?

licenses(["notice"]) # Apache 2.0

Ok, I'm quite stumped here. Could you please run bazel clean --expunge and try a clean build?

After bazel clean --expunge It only says
INFO: Starting clean.

After that when I run :
bazel build //main:hello-world

It gives, same invalid license type error.

/private/var/tmp/_bazel_cagrigider/4c2d107b81f30b45f844673a09f76011/external/bazel_tools/tools/cpp/BUILD:17:1: invalid license type: 'notice'

Something else worth trying is to check whether you are using the bazel that homebrew provides, using which bazel and whether bazel version returns bazel 0.13.0-homebrew. My homebrew bazel is located at /usr/local/bin/bazel.
Just in case you have a corrupt bazel installation...

which bazel
returns :
/usr/local/bin/bazel

And bazel version returns

Build label: 0.13.0-homebrew
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar

Could this be an encoding/parsing issue? + @laurentlb for Skylark

It could be that "notice".toUpperCase() on your system locale does not convert it to "NOTICE".

Is there anything I can do to fix this error?

Is there anything I can do to fix this error?

Sure, attach the debugger and check what is going on here https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/packages/License.java;l=200:

    licenseTypes.add(LicenseType.valueOf(str.toUpperCase()));

How can I attach the debugger on this code ?

See https://bazel.build/contributing.html, particularly "Debugging Bazel" section. Basically, you need to set up IntelliJ IDEA project, call Bazel with: bazel --host_jvm_debug build foo and attach remote debugger from the IDE to the specified port.

After I did this step when preparing IntelliJ IDEA install it from within the IDE (Settings > Plugins > Install > Browse Repositories, and search for 'Bazel').

I can't see that, Preferences > Other Settings > Bazel Settings on macOS IntelliJ IDEA

When I am did this install it from within the IDE (Settings > Plugins > Install > Browse Repositories, and search for 'Bazel'
I found only 'Bazel Build Formatter' plugin, Is that right one ?

And also, before creating project it wants me to build bazel .

cd bazel
bazel build //src:bazel
This will produce a working Bazel binary in bazel-bin/src/bazel.
If everything works fine, feel free to configure your favorite IDE in the following steps.

@cagrigider The IntelliJ plugin appears to only be supported in 2017.x versions (issue on their repo: https://github.com/bazelbuild/intellij/issues/290), so you are going to have to rollback to 2017.3.5 which is the last 2017 release. If you don't already, you may want to use the JetBrains Toolbox App which makes installing and upgrading to specific IntelliJ versions really easy.

It says Set the path to the Bazel binary in the plugin preferences

but bazel build //src:bazel is not working, so I don't have binary files. Am I right ?

Yes. You need to go to your Bazel settings (just type that into the box that pops up when you press Cmd+ Shift + A), there's a text box in the settings menu which you're taken to which says Bazel binary location -> paste whatever path which bazel returns in a shell. For me this path is /usr/local/bin/bazel. Then try again.

It says :
Start creating a debug configuration for both C++ and Java in your .bazelrc with the following:

build:debug -c dbg
build:debug --javacopt="-g"
build:debug --copt="-g"
build:debug --strip="never"

Then you can rebuild Bazel with bazel build --config debug //src:bazel and use your favorite debugger to start debugging.

So I should open my bazel.bazelrc file as a text file and paste these lines into it. Then rebuild ?

Now my .bazelrc file is empty

Could you please try passing the flag --host_jvm_args=-Duser.language=en to your bazel build command?

@cagrigider adding --config some_config to your execution of bazel is the same as adding all flags specific in the config into the command line, i.e. bazel build -c debug --javacopt="-g" --copt="-g" --strip="never" //src:bazel for the debug build.

As @jin indicated, it would also be good to try setting user.language: bazel --host_jvm_args=-Duser.language=en build //src:bazel. Then run your build with the resulting binary.

I m trying this now bazel --host_jvm_args=-Duser.language=en build //src:bazel and it s looking like working. It didn't give any license error.
If it finish successfully, it means it will work without any problem because of this flag settings ?

Yeah, it looks like the problem is with your system's locale setting. No worries, we should force the Locale to be en while performing str.toUpperCase in the code. I'll send in a fix.

If it finish successfully, it means it will work without any problem because of this flag settings ?

Yes, for now, you should run any bazel build command with the --host_jvm_args=-Duser.language=en. You can also add it into your project's .bazelrc file like this to not have to specify it every time:

# In $PROJECT/.bazelrc
startup --host_jvm_args=-Duser.language=en

It is working now.

Thank you so much.

Good to hear :-)

Was this page helpful?
0 / 5 - 0 ratings