Air-Gapped RStudio Package Manager¶
RStudio Package Manager communicates with a RStudio CRAN service to access CRAN packages and metadata. In offline environments, it is possible to directly download the necessary data from the RStudio CRAN service and then copy it to an offline RStudio Package Manager server.
This guide includes 3 sections:
- Instructions for an initial air-gapped setup (Initial Setup)
- Instructions for performing regular updates (Regular Updates)
- Instructions for upgrading RStudio Package Manager in an air-gapped environment (Air-Gapped Upgrading of RStudio Package Manager)
- Copy the file
/opt/rstudio-pm/bin/rspm-offline-downloaderto an online Linux server. If you would prefer to use a Windows server or desktop as your online machine, contact firstname.lastname@example.org.
Run the command
rspm-offline-downloader get-cran --helpto learn about the available options. When ready, you can run the command with the appropriate flags to perform the full download. These steps will download metadata, README files and package archives which total more than 50 GB of data and may take some time to complete.
If you enable binaries in offline environments, the size of the download will be larger depending on the number of R versions and operating systems selected.
The result will be a directory of files and subdirectories such as:
/path/to/destination/v3/version.txt /path/to/destination/v3/1 /path/to/destination/v3/1/... /path/to/destination/sysreqs
--include-binariesflag is used, additional directories will be created depending on the selected R versions and Linux distributions. For example, if the command is
rspm-offline-downloader get-cran ... --include-binaries --r-versions=3.4,3.5 --linux-distros=bionic,centos7then you should expect the following directories to be included:
/path/to/destination/bindex /path/to/destination/bin/3.4-bionic /path/to/destination/bin/3.5-bionic /path/to/destination/bin/3.4-centos7 /path/to/destination/bin/3.5-centos7
Enabling binaries in offline environments is optional. See the Serving Package Binaries section for more information on serving binaries.
Create a directory to store the data in the offline RStudio Package Manager server, such as
/var/lib/rspm-offline/cran. If you have a cluster of nodes, use shared storage for this directory.
sudo mkdir -p /var/lib/rspm-offline/cran
Copy the data downloaded in step 2 from the online machine to the directory on the offline RStudio Package Manager server. For completely isolated servers, you may need to copy the data to a physical drive in order to move it to the offline environment.
For example, if the downloaded data was located at
sudo cp -r /path/to/data/. /var/lib/rspm-offline/cran
Confirm by checking that the offline data directory has the same number of files as the original data directory. For example, the output of these two commands should be identical:
# Count the number of files in each subdirectory in /path/to/data find /path/to/data -type f -printf "%P\n" | cut -d/ -f1 | sort | uniq -c # Count the number of files in each subdirectory in /var/lib/rspm-offline/cran sudo find /var/lib/rspm-offline/cran -type f -printf "%P\n" | cut -d/ -f1 | sort | uniq -c
Finally, modify the permissions on the directory in the offline RStudio Package Manager server, changing ownership to the unix account running RStudio Package Manager,
sudo chown -R rstudio-pm:rstudio-pm /var/lib/rspm-offline/cran
Next, configure the offline RStudio Package Manager server to use the downloaded data. To do so, modify the RStudio Package Manager Configuration file to include the following properties in the
; /etc/rstudio-pm/rstudio-pm.gcfg [CRAN] ManifestURL = A URL in the form, `file:///<the directory you created in step 3>`
For example, if your CRAN data directory is at
/var/lib/rspm-offline/cran, the file
; /etc/rstudio-pm/rstudio-pm.gcfg [CRAN] ManifestURL = file:///var/lib/rspm-offline/cran
Once the file is updated, restart the RStudio Package Manager Service. If the configuration was successful, you should see a message like this in
Configured to serve CRAN data from a directory. Checking path '/var/lib/rspm-offline/cran'.
Follow the remainder of the instructions in the admin guide for setting up sources and repositories using the
rspmcommands in the offline RStudio Package Manager server. The
rspm synccommand will use the downloaded data to populate the necessary CRAN data and packages.
It is important to regularly update data available on the offline server. Updating this data does not automatically make new packages available to end users. The following process pushes updates from the RStudio CRAN service to RStudio Package Manager’s metadata. Follow the instructions in the admin guide to make updates available to end users. See the Admin CLI section for more information.
- If you have maintained the originally downloaded files, you can perform a
relatively fast update by re-running the
rspm-offline-downloadercommand. Subsequent command executions will simply add or update files as necessary without re-downloading the entire set.
- Copy the directory from the online machine to the folder created in the
offline RStudio Package Manager during the initial setup, e.g.
/var/lib/rspm-offline/cran. Ensure that the directory is still owned by the unix account running RStudio Package Manager,
Upgrading RStudio Package Manager¶
A new version of RStudio Package Manager may require data from a new version of the RStudio CRAN service. To ensure a smooth upgrade with limited downtime, we recommend the following steps:
- You will need a staging environment that mirrors your offline production server. After creating this environment, begin by upgrading the offline staging server to the latest RStudio Package Manager release.
- Follow the instructions for the Initial Setup of an Air-Gapped server in the Initial Setup section, using the offline staging server.
- After you have validated that everything works as expected, copy the
CRAN data, e.g.
/var/lib/rspm-offline/cran, from the offline staging server to the offline production server.
- Upgrade the offline production server to the new version of RStudio Package Manager.
(Optional) After an upgrade, navigate to the directory storing CRAN data, e.g.
/var/lib/rspm-offline/cran. This directory will contain versioned folders, e.g.
The output from
rspm-offline-downloader get-cranwill have indicated the version of the RStudio CRAN service required by the current version of RStudio Package Manager, e.g.
Performing full download of schema version v3.
You can safely remove all of the other folders in the directory. In this example, only