Unable to setwd() in Rsnippet after upgrade to R 4.2.2 and Rserve1.8-11

I’m using KNIME AP 4.6.3 as well as (occasionally) an older version 4.3.4.

I recently upgraded my R version to 4.2.2, and Rserve package to 1.8-11.

The R nodes all appear to work just fine, in either version of KNIME AP, with the new R and Rserve. I can produce tables or figures and see them coming out of the R nodes just fine. However, I have seen some unusual behavior when I try to use the ‘setwd()’ command (set working directory). I get an error after initial execution that you can see in the first figure, and then another error that may reflect some dependence on the ‘Cairo’ package in the second execution with the ‘R View (Table)’ node.

The inability to set the working directory is impacting my ability to write files to local directories of my choosing (e.g., png’s).

Any clues from the community as to what is going on?

@longoka could you just export the files from within R by using a full path, one that you could dynamically extract from the settings instead of switching the work directory of R?

This issue persists when I apply your suggestion.

I finally found a solution that worked. I think it indicates that the original issue was related to how the R::Cairo package (v1.6-0) is working specifically with KNIME, possibly XQuartz (2.8.2) also. The solution was simply to add the ‘device=png’ to the ggsave command:


It has never been necessary for me to designate the device before in the ggsave command; the file extension itself has always sufficed (e.g., *.png). I think this indicates that Cairo is not working as expected; it’s not automatically detecting the file type. This is interesting, because the ‘device=png’ is not needed for successful execution of the same script run in R/RStudio or in a Jupyter Notebook running an R kernel. So there is something different going on with the KNIME/R interaction.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.