我是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中遇到的其他错误有关。我认为更新后的权限存在问题。
答案 0 :(得分:1)
如果将依赖项包含在gradle文件中,则这些库将在类路径中可用,而无需使用AetherPackageLoader。