Attempt to load a CRAN package in TERR fails with error 'could not find function "isNamespaceLoaded"'

Attempt to load a CRAN package in TERR fails with error 'could not find function "isNamespaceLoaded"'

book

Article ID: KB0080258

calendar_today

Updated On:

Products Versions
Spotfire Enterprise Runtime for R 4.4.1 and earlier

Description

Attempt to load a user-contributed package from the open-source R community's CRAN repository into a TIBCO Enterprise Runtime for R (TERR) session's search() path fails with error 'could not find function "isNamespaceLoaded"'.

~~~

TERR 4.5.0 implemented the fix for this issue.

The latest client hotfix for Spotfire 7.14 (TS_7.14.0.42 HF-003, released October 24, 2018) upgrades the Spotfire Analyst desktop client's built-in local TERR engine to TERR 4.5.0.

The latest client hotfix for Spotfire 7.11.1 LTS (TS_7.11.1.20 LTS HF-012, released October 24, 2018) also upgrades the Spotfire Analyst desktop client's built-in local TERR engine to TERR 4.5.0.

 
Spotfire hotfixes are cumulative. Each hotfix contains all previous hotfixes.


TIBCO Spotfire Statistics Services (TSSS) 7.11.1 LTS ships with TERR 4.5.0 as its default statistical engine.


Information on Long Term Support (LTS) releases is provided at the following URL:

  https://docs.tibco.com/pub/spotfire/general/LTS/spotfire_LTS_releases.htm


 

Issue/Introduction

Attempt to load a CRAN package in TERR fails with error 'could not find function "isNamespaceLoaded"'

Environment

All supported environments

Resolution

This is a known issue with some CRAN packages (including "zoo", for example) that use the "tidyverse" family of packages.  

The following is the workaround for TERR 4.4.x and earlier:

Before loading a package that throws this error, define the following at the top of the TERR script, before anything else is done:


isNamespaceLoaded <- function(name) is.element(name, loadedNamespaces())

This allows the package to be loaded into the data function's TERR search() path:

> isNamespaceLoaded <- function(name) is.element(name, loadedNamespaces())
> library(zoo)



Important note for Spotfire data functions:

Any package that throws this error must only be loaded from inside the TERR script, after isNamespaceLoaded() has been defined in the script.

If the package name is included in the "Register Data Function" dialog's "Packages (separated by semicolons)" field for this data function, that will trigger a failed attempt to load the package before any of the TERR script can be run.