bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.3k stars 4.09k forks source link

use of $(JAVA) fails with genrule (0.1.5) #960

Closed perezd closed 6 years ago

perezd commented 8 years ago

If I use $(JAVA) in the cmd of a genrule, I get the following error:

/bin/bash: external/local_jdk/bin/java: No such file or directory

However, if I copy/paste the command generated by --verbose_failures, the command actually does work and finds that properly.

I am in Ubuntu linux, with Bazel 0.1.5. Current lame workaround is to use /usr/bin/java, which does work. Thoughts?

bsilver8192 commented 8 years ago

Sounds like an issue with sandboxing. Try the build with --sandbox_debug and see if external/local_jdk/bin/java shows up in the list of mounted paths. If that is the problem, I think adding @local_jdk//:java to your deps is the right solution.

perezd commented 8 years ago

OK, but this is actually a bug, right? genrule variables say $(JAVA) should be available.

perezd commented 8 years ago

I'm currently blocked by: #965 so I can't diagnose this further at this time.

ulfjack commented 8 years ago

You probably need to declare a java_binary rule with the classes you want to run and use that in the genrule with $(location).

If the genrule docs say $(JAVA) works, then they are mistaken.

perezd commented 8 years ago

I did as you recommended and now I get this error: external/local_jdk/bin/java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

bsilver8192 commented 8 years ago

That looks like #631, which means you need to add @local_jdk//:jdk to the deps too.

helenalt commented 6 years ago

Is this still an issue. There seems to be a few other related items that have been resolved over time.