How to set a custom library path for TIBCO Enterprise Runtime for R (TERR)

How to set a custom library path for TIBCO Enterprise Runtime for R (TERR)

book

Article ID: KB0075324

calendar_today

Updated On:

Products Versions
Spotfire Analyst All
Spotfire Desktop All

Description

By design, the installed client's (TIBCO Spotfire Analyst or TIBCO Spotfire Desktop) point-and-click "Tools > TERR Tools > Package Management" feature installs CRAN packages in a library folder that it finds or creates under the current user's Windows profile. This is also true when the installed client is hosted on a Citrix XenApp server.

Issue/Introduction

This article describes how to set a custom library path for where CRAN packages are installed by TIBCO Enterprise Runtime for R (TERR)

Resolution

One way to provide custom library path is to put custom code into the Spotfire desktop client's "TERRprofile.site" file:

In a TERR Console session launched using "Tools > TERR Tools > Launch TERR Console", the following command will show the path where the placeholder "TERRprofile.site" file is located:  

file.path(Sys.getenv("TERR_HOME"), "etc")
Once you know the location of "TERRprofile.site" file you can modify it according the example. Below is a modified "TERRprofile.site" example script. You will need to define your own value for the script's 'CustomUserLibraryPath' object, when you test it in your environment.
# TERR_HOME/etc/TERRprofile.site
# This file is sourced when TERR starts.

cat('\nTERR_HOME/etc/TERRprofile.site\n')
cat('\nThis file is sourced when TERR starts.\n')
cat('\nRunning TERRprofile.site\n\n')

CustomUserLibraryPath <- "C:/TERR/CustomUserLibraryTERR"

cat('\nCustomUserLibraryPath\n')
print(CustomUserLibraryPath)

if(file.exists(CustomUserLibraryPath))
{
  cat('\nSys.setenv(TERR_LIBS_USER = CustomUserLibraryPath)\n')
  Sys.setenv(TERR_LIBS_USER = CustomUserLibraryPath)

  cat('\nSys.getenv("TERR_LIBS_USER")\n')
  print(Sys.getenv("TERR_LIBS_USER"))

  cat('\n.libPaths(Sys.getenv("TERR_LIBS_USER"))\n')
  print(.libPaths(Sys.getenv("TERR_LIBS_USER")))
} else {
  cat(paste('\nUnable to find this specified CustomUserLibraryPath: "', CustomUserLibraryPath, '"\n', sep = ""))
}

cat('\n.libPaths()\n')
print(.libPaths())

cat('\nutils::installed.packages(lib = .libPaths()[1])[, "Version"]\n')
print(utils::installed.packages(lib = .libPaths()[1])[, "Version"])

cat('\nFinished running TERRprofile.site\n\n')
Please note, Both TERR and open-source R use a single slash ("/") as the path separator, even on Windows.  (A single backslash ("\") will not work, because the backslash is used as the first character in two-character escape sequences, such as "\t" for a tab and "\n" for a newline.)

Additional Information

Is there a way to bundle several R packages into a Spotfire package (*.spk file) that can be deployed from Spotfire Server to make them available to all of our Spotfire Analyst desktop clients?