orshachar
orshachar

Reputation: 5037

bazel remote worker deployable jar not working

I have an issue packing bazel-remote-worker into deployable jar.

I ran the following command:

bazel build //src/tools/remote_worker:remote_worker_deploy.jar

But when I try to run the jar I get this error:

➜  bazel git:(master) ✗ java -jar remote_worker_deploy.jar --work_path=/tmp/test --listen_port=3030
*** Initializing in-memory cache server.
*** Not using remote cache. This should be used for testing only!
Exception in thread "main" java.lang.UnsatisfiedLinkError: no unix in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at com.google.devtools.build.lib.UnixJniLoader.loadJni(UnixJniLoader.java:28)
    at com.google.devtools.build.lib.unix.NativePosixFiles.<clinit>(NativePosixFiles.java:136)
    at com.google.devtools.build.lib.unix.UnixFileSystem.createDirectory(UnixFileSystem.java:309)
    at com.google.devtools.build.lib.vfs.Path.createDirectory(Path.java:829)
    at com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParentsWithCache(FileSystemUtils.java:692)
    at com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParents(FileSystemUtils.java:652)
    at com.google.devtools.build.remote.RemoteWorker.<init>(RemoteWorker.java:114)
    at com.google.devtools.build.remote.RemoteWorker.main(RemoteWorker.java:621)

The only way I can start it is by running the executable from bazel-bin:

bazel-bin/src/tools/remote_worker/remote_worker --work_path=/tmp/test --listen_port=3030

I'm running bazel latest (currently a3e26835890a543ff84cce90c879f9196ae06348) on mac osx sierra.

I tried it with either oracle-jdk-1.8.131 or openjdk-1.8.91 and it behaved the same.

End goal is to create a docker image that runs this jar but even inside the openjdk:8 this jar acts the same...

Upvotes: 1

Views: 238

Answers (2)

user7610
user7610

Reputation: 28811

Since the question was asked, the paths in Bazel source tree have changed. Nowadays the build commands to get the _deploy.jar are as follows.

bazel build src/tools/remote:worker_deploy.jar
mkdir -p /tmp/cas /tmp/cache /tmp/work
java -jar bazel-bin/src/tools/remote/worker_deploy.jar \
  --cas_path /tmp/cas --disk_cache /tmp/cache --work_path /tmp/work
bazel build --spawn_strategy=remote \
  --remote_cache=grpc://${IP}:8080 --remote_executor=grpc://${IP}:8080

Upvotes: 1

Ulf Adams
Ulf Adams

Reputation: 1329

Apparently we're not packing the native code into the deploy jar. I'd actually prefer to refactor the RemoteWorker to avoid most of Bazel's internal libraries, although it's unlikely to happen soon. You could ship the libunix.so with the deploy jar and set the java.library.path appropriately. Alternatively, you can take the entire runfiles tree after building the remote worker (bazel-bin/src/tools/remote_worker/remote_worker.runfiles/).

Upvotes: 2

Related Questions