Table to R not able to load library

Hi,

macOS Sierra, KNIME 3.5.3, R 3.4.4 from homebrew:
I try to execute a simple command in a Table to R node:
library(MSstats)
Of course packages were installed beforehand and the command works in R. Similarly, other basic R commands work in the node.

I get the following error on the Workbench execunting the node with just the line above:

ERROR	 KNIME-Worker-1 Node	 Execute failed: R evaluation failed.: "knime.tmp.ret<-NULL;printError<-function(e) print(paste('Error:',conditionMessage(e)));for(exp in tryCatch(parse(text=knime.tmp.script),error=printError)){try(knime.tmp.ret<-eval(exp),silent=True)
if(!is.null(knime.tmp.ret)) {if(knime.tmp.ret$visible) try(print(knime.tmp.ret$value),silent=True)}};rm(knime.tmp.script,exp,printError);knime.tmp.ret$value"

Stacktrace:

DEBUG Table to R           0:16       Execute failed: R evaluation failed.: "knime.tmp.ret<-NULL;printError<-function(e) print(paste('Error:',conditionMessage(e)));for(exp in tryCatch(parse(text=knime.tmp.script),error=printError)){try(knime.tmp.ret<-eval(exp),silent=True)
    if(!is.null(knime.tmp.ret)) {if(knime.tmp.ret$visible) try(print(knime.tmp.ret$value),silent=True)}};rm(knime.tmp.script,exp,printError);knime.tmp.ret$value"
    org.knime.r.controller.IRController$RException: R evaluation failed.: "knime.tmp.ret<-NULL;printError<-function(e) print(paste('Error:',conditionMessage(e)));for(exp in tryCatch(parse(text=knime.tmp.script),error=printError)){try(knime.tmp.ret<-eval(exp),silent=True)
    if(!is.null(knime.tmp.ret)) {if(knime.tmp.ret$visible) try(print(knime.tmp.ret$value),silent=True)}};rm(knime.tmp.script,exp,printError);knime.tmp.ret$value"
    	at org.knime.r.controller.RController.monitoredEval(RController.java:432)
    	at org.knime.r.controller.ConsoleLikeRExecutor.executeIgnoreResult(ConsoleLikeRExecutor.java:247)
    	at org.knime.r.RSnippetNodeModel.runRScript(RSnippetNodeModel.java:256)
    	at org.knime.r.RSnippetNodeModel.executeSnippet(RSnippetNodeModel.java:206)
    	at org.knime.r.RSnippetNodeModel.executeSnippet(RSnippetNodeModel.java:170)
    	at org.knime.r.RSnippetNodeModel.executeInternal(RSnippetNodeModel.java:149)
    	at org.knime.r.RSnippetNodeModel.execute(RSnippetNodeModel.java:136)
    	at org.knime.core.node.NodeModel.executeModel(NodeModel.java:567)
    	at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1172)
    	at org.knime.core.node.Node.execute(Node.java:959)
    	at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:561)
    	at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:95)
    	at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:179)
    	at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:110)
    	at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:328)
    	at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:204)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
    	at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)
    Caused by: org.knime.r.controller.IRController$RException: R evaluation failed.: "knime.tmp.ret<-NULL;printError<-function(e) print(paste('Error:',conditionMessage(e)));for(exp in tryCatch(parse(text=knime.tmp.script),error=printError)){try(knime.tmp.ret<-eval(exp),silent=True)
    if(!is.null(knime.tmp.ret)) {if(knime.tmp.ret$visible) try(print(knime.tmp.ret$value),silent=True)}};rm(knime.tmp.script,exp,printError);knime.tmp.ret$value"
    	at org.knime.r.controller.RController.eval(RController.java:421)
    	at org.knime.r.controller.RController$MonitoredEval.lambda$0(RController.java:1430)
    	at org.knime.r.controller.RController$MonitoredEval$$Lambda$171/160883583.call(Unknown Source)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at org.knime.core.util.ThreadUtils$3.runWithContext(ThreadUtils.java:486)
    	at org.knime.core.util.ThreadUtils$ThreadWithContext.run(ThreadUtils.java:304)
    Caused by: org.rosuda.REngine.Rserve.RserveException: voidEval failed, request status: error code: 127
    	at org.rosuda.REngine.Rserve.RConnection.voidEval(RConnection.java:182)
    	at org.knime.r.controller.RController.eval(RController.java:416)
    	... 5 more

In the configuration dialogue i get additionally:

java.net.SocketException: Broken pipe
    	at java.net.SocketOutputStream.socketWrite0(Native Method)
    	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    	at java.net.SocketOutputStream.write(SocketOutputStream.java:141)
    	at org.rosuda.REngine.Rserve.protocol.RTalk.request(RTalk.java:205)
    	at org.rosuda.REngine.Rserve.protocol.RTalk.request(RTalk.java:180)
    	at org.rosuda.REngine.Rserve.protocol.RTalk.request(RTalk.java:250)
    	at org.rosuda.REngine.Rserve.RConnection.eval(RConnection.java:231)
    	at org.knime.r.controller.RController.eval(RController.java:413)
    	at org.knime.r.controller.RController$MonitoredEval.lambda$0(RController.java:1430)
    	at org.knime.r.controller.RController$MonitoredEval$$Lambda$169/694497285.call(Unknown Source)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at org.knime.core.util.ThreadUtils$3.runWithContext(ThreadUtils.java:486)
    	at org.knime.core.util.ThreadUtils$ThreadWithContext.run(ThreadUtils.java:304)

Side notes:
Even executing

knime.tmp.ret<-NULL;printError<-function(e) message(paste('Error:',conditionMessage(e)));tryCatch(knime.tmp.ret<-withVisible(eval(library(MSstats))),error=printError);if(!is.null(knime.tmp.ret)) { if(knime.tmp.ret$visible) {tryCatch(print(knime.tmp.ret$value),error=printError)}};rm(printError);knime.tmp.ret$value

works in R directly.

In the configure dialogue, I get additionally:

    library('Cairo');options(device='png',bitmapType='cairo')
    png("/private/var/folders/3w/sgbzzwr94nz6n61hdw97b7740000gn/T/knime_iPRG_2015_lfq_a57868/rtmp-dialog-57873/rsnippet-plot.png",width=400.0,height=300.0)"ERROR: R evaluation failed.: "library('Cairo');options(device='png',bitmapType='cairo')
    png("/private/var/folders/3w/sgbzzwr94nz6n61hdw97b7740000gn/T/knime_iPRG_2015_lfq_a57868/rtmp-dialog-57873/rsnippet-plot.png",width=400.0,height=300.0)"ERROR: eval failed, request status: error code: 127

but loading a standard library like dplyr works.

By the way:
Once a failed script was executed in the configure dialogue, it cannot recover and scripts that work before, do not work in that dialogue anymore.

Any ideas? Or any idea how to debug?

Hi jpfeuffer,

do you have Cairo installed? You should be able to test this by creating a RView Table node and trying to execute that.
When this error appears, that is likely due to an error being printed during a custom “print()” of some object.

I don’t know this packages, but it could be that MSstats prints its table or something similarly to ggplot2, hence, when “print()” is called on it implicitly after execution of a line.
When this causes an error like “Cairo not found” or something, this was not correctly handled in KNIME until very recently (should be fixed in the next release).

Hope that solves the problem.
Cheers, Jonathan.

I solved the x11/cairo problem by using the official R.pkg for macOS from CRAN.
The brew version is compiled without cairo and x11 support. Weirdly I could install the Cairo package, though.

The initial main problem remains.

Thanks for the suggestion, I would have to check that. A question that I was asking myself is: Can this happen during the “library” call already?

And I think I tracked it down to one of its dependencies, namely:
MSnbase

Since:
library(MSnbase)

already fails. In R it works fine without any warnings in verbose mode.

Ok. Even further down the rabbit hole.
Can you try:
library(BiocInstaller)

which should be a very basic package. This crashes for me.
Also
source("http://bioconductor.org/biocLite.R")

fails for me.

Yes, the Rserve instance you start up has problems reaching the internet.
Sourcing any file from the internet fails.

Putting it into the Rserv.conf you generate with
eval library(BiocInstaller)
solves it.

Could you maybe add an option to specify additions to the Rserv.conf from the KNIME->R settings in 3.6?

Do you have an idea for a quick workaround that does not involve modifying the Rserv.conf? Why can’t it reach the internet?

Possibly related to:
https://www.knime.com/forum/r-statistics-nodes-and-integration/knime340-on-macos-sierra-10126-r341-integration-does-not-0

Could it be that Rserve is blocked by your firewall? The Rserve executable should be in site-library/Rserve/ or library/Rserve or similar.

This crashes for me.

How does it crash? I don’t expect this is refering to the entire analytics platform crashing, but rather the Rserve process?
You could try a nightly build, it should display more useful error messages.

Was this ever resolved?
I am getting the same error with Knime 3.6 as well. I can not seem to execute any R node. I do seem to think that I was able to do it earlier.

Hey pvaish! Which R version are you using? (In advance: R 3.5 / Rserve 1.8-5 have problems that prevent them from working with KNIME)

Could be this. Does it work with R 3.4.4?

R 3.5 - macOSX problems

Just a heads-up: After 5 years, this error still exists in KNIME 4.7.2 with R 4.something.
Users will not be able to install certain libraries from inside KNIME on macOS.