RinR::REvaluate() in TERR 4.5 throws "Error in readRDS(rdsFile)" when using open-source R 3.6 engine

RinR::REvaluate() in TERR 4.5 throws "Error in readRDS(rdsFile)" when using open-source R 3.6 engine

book

Article ID: KB0075170

calendar_today

Updated On:

Products Versions
Spotfire Enterprise Runtime for R 4.5.0

Description

REvaluate() function from the built-in RinR package in TERR 4.5.0 throws the following error when using an open source R 3.6.x (and above) engine to execute R commands: 

"Error: Error in readRDS(rdsFile): file '...' was saved with a newer version, please upgrade"


For example, in a TERR 4.5.0 Console session:

=====
TIBCO Software Inc. Confidential Information
Copyright (C) 2011-2018 TIBCO Software Inc. ALL RIGHTS RESERVED
TIBCO Enterprise Runtime for R version 4.5.0 for Microsoft Windows 64-bit

Type 'help()' for help.
Type 'q()' to quit.
>
>
> # This command displays the TERR version in use during this session:
>
> version$TERR.version
[1] "4.5.0"
>
>
> # The following command displays the open-source R version that was
> # used as the comparison and compatibility reference during QC tests
> # for this TERR release.  This is the best open-source R version
> # to use with functions from this TERR release's "RinR" package: 
>
> getRversion()
[1] '3.4.4'
>
>
> # The following command shows the "RinR" package version
> # being used in this session. It is the version that is included
> # in this TERR release:
>
> packageVersion("RinR")
[1] '4.5.0.113'
>
>
> library(RinR)
>
>
> RPath <- "C:/Program Files/R/R-3.6.2/bin"
>
> RinR::pushPATH(RPath)
>
> REvaluator <- makeREvaluator("R", RBinDir = RPath)
>
>
> res <- REvaluate(installed.packages(), REvaluator)
>
>
> cat(res)
Error: Error in readRDS(rdsFile): file 'C:\Users\MyUserID\AppData\Local\Temp\TERR_220400291\file220469529' was saved with a newer version, please upgrade
>
>
> REvaluate(installed.packages(), REvaluator)
[1] "Error: Error in readRDS(rdsFile): file 'C:\\Users\\MyUserID\\AppData\\Local\\Temp\\TERR_23c048232\\file23c069529' was saved with a newer version, please upgrade\n"
>
>
> # Specifying "verbose = TRUE" provides a more detailed look
> # at the processes that lead to the error: 
>
> REvaluate(installed.packages(), REvaluator, verbose = TRUE)
RinR::REvaluate expr= try(installed.packages())
C:\Program Files\R\R-3.6.2\bin\R: `_value` <- structure(names=sub("TIBCO Enterprise Runtime for R", "TERR", version$version.string), list(try(
C:\Program Files\R\R-3.6.2\bin\R: {
C:\Program Files\R\R-3.6.2\bin\R: setwd("C:/Users/MyUserID.Analytics")
C:\Program Files\R\R-3.6.2\bin\R: eval(readRDS("C:\\Users\\MyUserID\\AppData\\Local\\Temp\\TERR_23c048232\\file23c00bb311"), envir=.GlobalEnv)
C:\Program Files\R\R-3.6.2\bin\R: }
C:\Program Files\R\R-3.6.2\bin\R: )))
C:\Program Files\R\R-3.6.2\bin\R: saveRDS(`_value`, file="C:\\Users\\MyUserID\\AppData\\Local\\Temp\\TERR_23c048232\\file23c041bbe")
C:\Program Files\R\R-3.6.2\bin\R: q("no")
C:\Program Files\R\R-3.6.2\bin\R: cmd /S /C " "C:\Program Files\R\R-3.6.2\bin\R" --arch 64 --quiet --slave --no-init-file --no-restore --no-save < "C:\Users\MyUserID\AppData\Local\Temp\TERR_23c048
232\file23c026e9f" > "C:\Users\MyUserID\AppData\Local\Temp\TERR_23c048232\file23c001eb10" 2>&1 "
R: exit status =0
[1] "Error: Error in readRDS(rdsFile): file 'C:\\Users\\MyUserID\\AppData\\Local\\Temp\\TERR_23c048232\\file23c041bbe' was saved with a newer version, please upgrade\n"
=====
 

Environment

All supported environments

Resolution


RinR::REvaluate() in TERR 4.5.0 can communicate with an open-source R 3.4.x or 3.5.x engine. 

RinR::REvaluate() in TERR 5.0.0 or later can communicate with an open-source R 3.6.x engine. 


Analysis:

When the user sets the open-source R engine path to 3.6.x (e.g. 3.6.2), it uses the R 3.6.x engine to run the R code within the RinR::REvaluator, and the R 3.6.2 engine's execution output will be saved as a temporary R data file (RDS file).

The RDS file returned from the open-source R engine has a serialization format version. Newer versions of R, starting from R 3.6.0, will use serialization format version 3 as the default format when saving the workspace (using a call to saveRDS(), for example).

This change is reported in the following R 3.6.0 document from the open-source R community's CRAN site:

https://cran.r-project.org/bin/windows/base/old/3.6.0/NEWS.R-3.6.0.html

See the following item from that document's "Changes in R 3.6.0" section:

-----------------------------------------
* Serialization format version 3 becomes the default for serialization and saving of the workspace (save(), serialize(), saveRDS(), compiler::cmpfile()). Serialized data in format 3 cannot be read by versions of R prior to version 3.5.0.
-----------------------------------------

The TERR 4.5.0 engine is compatibility tested against R version 3.4.4.

In earlier versions of the open-source R and TERR engines (e.g. R 3.4.4 and TERR 4.5.0), the readRDS() function is not able to read RDS files of serialization format version 3.

When you execute RinR::REvaluate() in TERR 4.5.0, it calls the readRDS() function to read the temporary output RDS file of default serialization format 3 saved by the R version 3.6.2 engine.

That is where the reported error comes from.

When you set the R engine path to point to an open-source R 3.5.x instance, then run R code within TERR's RinR::REvaluator, the R 3.5.x engine will save its output in a temporary RDS file of serialization format version 2.

An RDS file of serialization format 2 can be read by TERR engine 4.5.0. So RinR::REvaluate() in TERR 4.5.0 works fine with an open-source R 3.5.x engine. 

Furthermore, TERR engine 5.0.0 is compatibility tested against R version 3.5.2, which is able to read RDS files of serialization format version 3.

So the test script works fine in TERR 5.0.0 when using R 3.6.x engine within REvaluate: see below.

=====
TIBCO Software Inc. Confidential Information
Copyright (C) 2011-2019 TIBCO Software Inc. ALL RIGHTS RESERVED
TIBCO Enterprise Runtime for R version 5.0.0 for Microsoft Windows 64-bit

Type 'help()' for help.
Type 'q()' to quit.
>
>
> getRversion()
[1] '3.5.2'
>
>
> version$TERR.version
[1] "5.0.0"
>
>
> library(RinR)
>
>
> RPath = "C:/Program Files/R/R-3.6.3/bin"
>
>
> RinR::pushPATH(RPath)
>
>
> REvaluator <- makeREvaluator("R", RBinDir = RPath)
>
>
> REvaluate(installed.packages(), REvaluator)
Package LibPath Version
base "base" "C:/Program Files/R/R-3.6.3/library" "3.6.3"
boot "boot" "C:/Program Files/R/R-3.6.3/library" "1.3-24"
class "class" "C:/Program Files/R/R-3.6.3/library" "7.3-15"
.....
>
>
=====


Therefore, you can consider the following solutions to avoid this issue:
1. If you want to still use TERR 4.5.0 and do not want to upgrade TERR, you may consider using an R version lower than 3.6.0 in order to generate temporary RDS files of serialization format version 2 for TERR 4.5.0 to read.
2. If you want to use R 3.6.0 or later, please upgrade from TERR 4.5.0 to TERR 5.0.0 or later, which is able to read RDS files of serialization format 3.


=========================
Important note on use of open-source R:

Open-source R is available under separate open source software license terms and is not part of the TIBCO Spotfire product line. As such, R is not within the scope of your license for any TIBCO Spotfire product. R is not supported, maintained, or warranted in any way by TIBCO Software Inc. Download and use of R is solely at your own discretion and subject to the free open source license terms applicable to R.
=========================

 

Issue/Introduction

RinR::REvaluate() in TERR 4.5 throws "Error in readRDS(rdsFile)" when using open-source R 3.6 engine

Additional Information

https://cran.r-project.org/bin/windows/base/old/3.6.0/NEWS.R-3.6.0.html