# Package Installation Locations and Recommendations for Updating

You can use packages installed with TERR and with TERR in Spotfire Analyst, you can create and share your own packages, and you can download packages from a package repository. In all cases, you should know where they are installed and how they behave when you update your TERR or Spotfire installation.

Note:
Due to changes in open-source R version 3.5 and resulting compatibility changes in TERR 5.0, packages that are built with a version of TERR prior to 5.0 must be rebuilt.

- To install a binary package from a repository, always call `install.packages(pkgname)` from TERR. The `install.packages` function finds the correct binary version in the repository for your version of TERR. Manually downloading the binary package from CRAN can result in errors when you use it with TERR.
- To install a package from source, try installing it first with TERR (with `install.packages` in TERR or with `TERR CMD INSTALL` from a command line).
- To install a package from source that you cannot build with TERR, install the package with the version of open-source R tested with TERR.

This topic details where packages are installed by default with TERR, for those that you download and install from a package repository using the TERR console, those that you install using TERR Tools in Spotfire Analyst, and for those that you install from an SPK distributed by Spotfire Server.

Tip: From Spotfire Analyst TERR Tools, you can open the console and at the prompt, run the following commands to learn more about the location of installed packages.

- Run the function `.libPaths()` to discover where TERR finds packages. This is especially useful if you do not have write access to the Program Files directory on a Windows computer.
- Run the function `installed.packages()` to retrieve a list of all packages installed on the computer, and to discover other pertinent information, including where they are installed.
  Tip: In Spotfire Analyst, you can use the TERR Tools Package Management tab to see a list of installed packages.

Installed by default with the TERR console application

  Default Installation location | Description | Updating to a new version of TERR
  --- | --- | ---
  TERR_HOME/library | Do not remove or change these packages. Doing so can cause unexpected behavior. | When you install a new version of TERR, the old library directory is removed and the packages are deleted. Updated versions of the packages are installed with the new version of TERR.

Installed by default with TERR in Spotfire Analyst

  Default Installation location | Description | Updating to a new version of TERR
  --- | --- | ---
  SPOTFIRE_HOME/Modules/TERR_version/engine/library | Do not remove or change these packages. Doing so can cause unexpected behavior. | When you install a new version of Spotfire Analyst, the old TERR library directory is removed and the packages are deleted. Updated versions of the TERR packages are installed with the new version of Spotfire Analyst.

Installed from a package repository using the console application

  Default Installation location | Description | Updating to a new version of TERR
  --- | --- | ---
  TERR_HOME/site-library | Packages downloaded from a repository are placed in this directory. On Windows, you must have write access to TERR_HOME for them to be installed at this location. If you do not have write access, packages you download are installed in the user directory. On Windows, this directory is [My Documents]/TERR/x86_64-pc-windows-library/version. | When you install a new version of TERR, the path to the older installation TERR_HOME/site-library is retained. You can take one of the following two steps. Browse to the directory site-library for the older installation, and move the packages to the new installation directory TERR_HOME/site-library. (If you do not have write access, manage your packages by copying them from the older version to the new version in the user directory location.) Download and reinstall the packages.

  For more information, see Manage your packages when you install a new version of Spotfire Enterprise Runtime for R.

Downloaded and installed using TERR Tools in Spotfire Analyst

  Default Installation location | Description | Updating to a new version of Spotfire
  --- | --- | ---
  [My Documents]/TERR/x86_64-pc-windows-library/version | In all cases, packages downloaded from the repository using TERR Tools are placed in this directory. | When you install a new version of Spotfire Analyst, the path to the user library is retained. Browse to the version directory for the older installation and move the packages to the new installation version directory . Use TERR Tools to download and reinstall the packages. .

  For more information, see Manage packages using Spotfire and Spotfire Enterprise Runtime for R.

Installed by an SPK distributed in an update by Spotfire Server

  Default Installation location | Description | Updating to a new version of Spotfire Analyst
  --- | --- | ---
  SPOTFIRE_HOME/Modules/TERR Packages/libraryversion | Custom packages provided to you through an update when you connect to Spotfire Server are placed in this directory. | The packages provided to you through an update by Spotfire Server should be reinstalled by the Spotfire Server.

  For more information, see The Spofire SPK.

Installed on Spotfire Statistics Services

  Default Installation location | Description | Updating to a new version of Spotfire Analyst
  --- | --- | ---
  SPSERVER_HOME/data/appdata/library for a single server, or SPSERVER_SHARE/data/appdata/library for a cluster. | Packages that are uploaded to Spotfire Statistics Services for use by any client connecting to the Spotfire Statistics Services server. Your server administrator is responsible for setting the package location property, if necessary. | Your server administrator should preserve the data directory during updating.