google / shipshape

Program analysis platform
Apache License 2.0
269 stars 35 forks source link

Trouble with building using Bazel #54

Closed ciera closed 9 years ago

ciera commented 9 years ago

I got the following email from Yu Lin.

I can't build shipshape anymore (my plugin works fine before this upgrade), it gives the following error:

Loading... Loading complete. Analyzing... Found 171 targets... blaze: Entering directory `/home/yulin/.cache/bazel/_bazel_yulin/5f4d978cf0eb54a79459fe5f5f58e11b/s2/' [0 / 38] BazelWorkspaceStatusAction stable-status.txt __From ProtocJava shipshape/proto/shipshape_config_proto_java_src.srcjar: /bin/bash: line 4: jar: command not found ERROR: /home/yulin/Downloads/s2/tools/build_rules/genproto.bzl:127:5: error executing shell command: 'set -e rm -rf bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs mkdir bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_pr...' failed: bash failed: error executing com\ mand (cd /home/yulin/.cache/bazel/_bazel_yulin/5f4d978cf0eb54a79459fe5f5f58e11b/s2 && \ exec env - \ /bin/bash -c 'set -e rm -rf bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs mkdir bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs bazel-out/local_linux-fastbuild/bin/third_party/proto/protoc --java_out=bazel-out/local_linux-fastbuild/genfiles/shipshape/prot\ o/shipshape_config_proto_java_src.srcjar.srcs shipshape/proto/shipshape_config.proto jar cMf bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar -C bazel-out/local_linu\ x-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs . rm -rf bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs'): com.google.devto\ ols.build.lib.shell.BadExitStatusException: Process exited with status 127: bash failed: error executing command (cd /home/yulin/.cache/bazel/_bazel_yulin/5f4d978cf0eb54a79459fe5f5f58e11b/s2 && \ exec env - \ /bin/bash -c 'set -e rm -rf bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs mkdir bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs bazel-out/local_linux-fastbuild/bin/third_party/proto/protoc --java_out=bazel-out/local_linux-fastbuild/genfiles/shipshape/prot\ o/shipshape_config_proto_java_src.srcjar.srcs shipshape/proto/shipshape_config.proto jar cMf bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar -C bazel-out/local_linu\ x-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs . rm -rf bazel-out/local_linux-fastbuild/genfiles/shipshape/proto/shipshape_config_proto_java_src.srcjar.srcs'): com.google.devto\ ols.build.lib.shell.BadExitStatusException: Process exited with status 127. blaze: Leaving directory`/home/yulin/.cache/bazel/_bazel_yulin/5f4d978cf0eb54a79459fe5f5f58e11b/s2/' __Building complete. ____Elapsed time: 1.021s, Critical Path: 0.55s

It says "jar: command not found", but jar can be executed actually. Do you know why?

collinw commented 9 years ago

What version of Bazel is Yu Lin using?

yulin2 commented 9 years ago

I cloned it from github bazel's master branch. I found if I cp 'jar' into /usr/bin, I can compile.

collinw commented 9 years ago

Is jar not on your PATH by default?

yulin2 commented 9 years ago

It is on my path and I can execute it. But bazel still reports "jar: command not found". However, after I did "ln -s real/path/to/jar /usr/bin/jar", I can compile. I think it might be a issue of bazel. See here: https://github.com/google/bazel/issues/245

collinw commented 9 years ago

What is your JAVA_HOME? I just ran into my own problems using Bazel with a not-quite-right JAVA_HOME value: https://github.com/google/bazel/issues/268

yulin2 commented 9 years ago

My original JAVA_HOME was /usr/lib/jvm/java-7-openjdk-amd64. But I renamed java-7-openjdk-amd64 to openjdk-7 and set JAVA_HOME to /usr/lib/jvm/openjdk-7 (because I couldn't build the master branch of bazel when using name java-7-openjdk-amd64). Probably this action broke the symlink usr/bin/jar -> /etc/alternatives/jar -> /usr/lib/jvm/java-7-openjdk-amd64/bin/jar, thus raised the above error.

Now that I checkout bazel version 43b2ea7, I can build it using JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64. I restored the symlinks, and now I can build shipshape.