尝试通过 Java 子进程运行 swiftlint 失败(通过命令行正常工作)
我有一个Java程序来运行不同种类的衬里,使用ProcessBuilder将衬里称为过程。到目前为止,其他Linter的工作大部分都在工作,但是在Swiftlint中,
当我正常从命令行运行时,
swiftlint --enable-all-rules
我正面临一个奇怪的问题,它可以很好地工作,但是通过我的Java子过程实用程序执行相同的问题,
ProcessBuilder processBuilder = new ProcessBuilder("swfitlint", "--enable-all-rules");
Process process = processBuilder.start();
它会失败。 乍一看,以下错误消息
SourceKittenFramework/library_wrapper.swift:31: Fatal error: Loading libsourcekitdInProc.so failed
似乎是由于某些原因,Java程序某些库在通过bash启动命令时可用,而只是为了 当然,我尝试通过我的子过程utif运行以下命令
swiftlint --version
swift --version
,这意味着Java确实可以访问我的机器上安装的Swift二进制文件。任何帮助将不胜感激。
I have a java program to run different kinds of linters, calling the linters as a process using ProcessBuilder. So far, other linters have worked for the most part but with swiftlint, i'm facing a strange issue
When I run it normally from the command line, with
swiftlint --enable-all-rules
It works perfectly, but executing the same through my Java subprocess utility
ProcessBuilder processBuilder = new ProcessBuilder("swfitlint", "--enable-all-rules");
Process process = processBuilder.start();
It fails with the following error message
SourceKittenFramework/library_wrapper.swift:31: Fatal error: Loading libsourcekitdInProc.so failed
At first glance it seems like for some reason certain libraries are not available to the java program which are available to when firing a command through bash, but just to be
sure, I tried running the following command through my subprocess util
swiftlint --version
swift --version
Both of which worked, meaning Java does have access to swift binaries installed on my machine. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我仍然不完全确定为什么会发生这种情况,但我相信这是由于我的机器本身的某种环境问题造成的。
我尝试在 docker 容器内运行相同的代码,该容器使用从以下基本映像构建的映像
,并且它刚刚工作
I'm not still not entirely sure why this happens but i believe it's due to some kind of environment issue on my machine itself.
I tried running the same code inside of a docker container that uses the image built from the following base images
and it just worked