【问题标题】:bazel remote worker deployable jar not workingbazel远程工作者可部署的jar不工作
【发布时间】:2020-09-24 04:14:47
【问题描述】:

我在将 bazel-remote-worker 打包到可部署的 jar 中时遇到问题。

我运行了以下命令:

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

但是当我尝试运行 jar 时,我得到了这个错误:

➜  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)

我可以启动它的唯一方法是从bazel-bin 运行可执行文件:

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

我正在 mac osx sierra 上运行最新的 bazel(当前为 a3e26835890a543ff84cce90c879f9196ae06348)。

我用oracle-jdk-1.8.131openjdk-1.8.91 尝试了它,它的行为相同。

最终目标是创建一个运行此 jar 的 docker 映像,但即使在 openjdk:8 内部,此 jar 的行为也一样...

【问题讨论】:

    标签: java build bazel


    【解决方案1】:

    显然我们没有将本机代码打包到部署 jar 中。我实际上更愿意重构 RemoteWorker 以避免大部分 Bazel 的内部库,尽管它不太可能很快发生。您可以将 libunix.so 与部署 jar 一起发送并适当地设置 java.library.path。或者,您可以在构建远程工作者 (bazel-bin/src/tools/remote_worker/remote_worker.runfiles/) 后获取整个运行文件树。

    【讨论】:

      【解决方案2】:

      自从提出问题以来,Bazel 源代码树中的路径发生了变化。现在获取_deploy.jar的构建命令如下。

      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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-12
        相关资源
        最近更新 更多