# Installing R Packages Manually

If you have write permission to the computer hosting the TERR service, then you can install packages to a specific location manually, and then point to the package location in the custom configuration.

## About this task

Perform this task on the computer hosting the TERR service (in the directory where the TERR engine is installed), and then on the computer where Spotfire Server is installed.

This method of installing packages is useful for packages that have a larger number of dependent packages. Dependent packages are installed by default, rather than manually, using this method.

Any time you install additional packages or update existing packages, be sure to install them in the directory you specified for your `packagePath`. You can have only one package path for the TERR service installation.

## Before you begin

You must have administrative privileges to create a directory where packages are installed. You must have administrative privileges and the tools password to update the custom.properties file.

## Procedure

1. On the host computer, create a directory to hold the packages.
   You need to perform this step just the first time you install packages.
   Example: /opt/r/library
2. From a command prompt, launch TERR console.
   You can find the TERR engine in the /nodemanager/<version_#>/nm/services/<TERR Service name_guid#> /terr/bin directory.
3. Install the packages to the directory you created, and where the TERR service can find them.
   In this example, the survival package and its dependent packages are installed in the directory /opt/terr/library.

       install.packages("survival", lib="/opt/terr/library")

   The package and its dependent packages are installed.
4. Close the TERR console.
   At the TERR command prompt, run the command `q()`.
   The TERR console closes.
5. Update the TERR service configuration to specify the package path.
   You need to export, edit, and reimport the custom.properties file only the first time to set the package path.
   Note: Remember that when you change the custom.properties, you must edit the service configuration with a new name, and then reimport it to have it take effect. See Manually editing the service confguration files for more information.
   1. Follow steps 1-3 in Configuring the Service to export the service configuration file custom.properties.
   2. In the exported custom.properties file, locate the entry for `packagePath`.
   3. Provide the path that you specified for the installed packages.
      Note: The configuration setting `packagePath` requires forward slashes (/) regardless of operating system.
   4. Complete the steps to rename, save, update, and import the changed service configuration file, as described in Configuring the Service.