我是 Renjin 的新手,无法使用 AetherPackageLoader 安装软件包。我遇到了与Renjin can't load pckages但看似正确的 Gradle 文件相同的错误(请注意 a4Base 依赖项):
testCompile group: 'junit', name: 'junit', version: '4.12'
compile "org.renjin:renjin-script-engine:3.5-beta43";
// compile group: 'org.renjin.cran', name: 'e1071', version: '1.7-2-b1'
compile group: 'org.renjin', name: 'renjin-aether-package-loader', version: '0.8.1938'
compile "org.renjin.bioconductor:a4Base:1.27.0-b3"
完整的错误是:
18:08:35: Executing task 'PackageTest.main()'...
Starting Gradle Daemon...
Gradle Daemon started in 1 s 867 ms
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :PackageTest.main() FAILED
Using local repository: /Users/miguel/.m2/repository
Exception in thread "main" java.lang.RuntimeException: org.renjin.eval.EvalException: org.renjin.aether.AetherPackageLoader.load(Lorg/renjin/primitives/packaging/FqPackageName;)Ljava/util/Optional;
at org.renjin.eval.SessionBuilder.build(SessionBuilder.java:192)
at PackageTest.main(PackageTest.java:26)
Caused by: org.renjin.eval.EvalException: org.renjin.aether.AetherPackageLoader.load(Lorg/renjin/primitives/packaging/FqPackageName;)Ljava/util/Optional;
at org.renjin.sexp.Closure.applyPromised(Closure.java:212)
at org.renjin.sexp.Closure.apply(Closure.java:133)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.eval.Context.evaluate(Context.java:282)
at org.renjin.eval.Context.evaluate(Context.java:209)
at org.renjin.eval.SessionBuilder.build(SessionBuilder.java:187)
... 1 more
Caused by: java.lang.AbstractMethodError: org.renjin.aether.AetherPackageLoader.load(Lorg/renjin/primitives/packaging/FqPackageName;)Ljava/util/Optional;
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:152)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
at org.renjin.primitives.packaging.Packages.library(Packages.java:39)
at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:68)
at org.renjin.primitives.R$primitive$library.applyPromised(R$primitive$library.java:33)
at org.renjin.sexp.BuiltinFunction.apply(BuiltinFunction.java:100)
at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:46)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.eval.Context.evaluate(Context.java:282)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:39)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.sexp.Closure.applyPromised(Closure.java:200)
... 6 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':PackageTest.main()'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 48s
2 actionable tasks: 2 executed
18:09:24: Task execution finished 'PackageTest.main()'.
示例代码仅使用 AetherPackageLoader 实例配置会话,并尝试执行加载需要安装的库的 R 命令。当会话生成器创建会话并加载默认包时,代码会更快失败。
AetherPackageLoader loader = new AetherPackageLoader();
loader.setRepositoryListener(new ConsoleRepositoryListener(System.out));
loader.setTransferListener(new ConsoleTransferListener(System.out));
Session session = new SessionBuilder()
.withDefaultPackages()
.setPackageLoader(loader)
.build();
RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
RenjinScriptEngine engine = factory.getScriptEngine(session);
String code = "library('digest')";
SEXP sexp = (SEXP)engine.eval(code);
System.out.println(sexp);
对于 AetherPackageLoader 的任何帮助,我将不胜感激。我阅读了文档,但无法说出缺少什么。非常感谢,米格尔
编辑:我无法在 Windows PC 上重现此错误。我相信这与我在更新到 MacOS Catalina 后在 RStudio 中遇到的其他错误有关。我认为更新后的权限有问题。