rig: R Installation Manager

repository·main·Indexed 21 days ago

https://github.com/r-lib/rig

rig is an R Installation Manager for macOS, Windows, and Linux designed to simplify installing, removing, and managing multiple R versions. It supports symbolic names (e.g., devel, release), provides quick terminal links to specific versions, and manages Rtools on Windows. Key features include a macOS menu bar app for interactive version selection, shell auto-complete for zsh and bash, and a versioned user package library approach to ensure clean environments and persistent packages across R installations.

Tokens
25.2K
Snippets
111
Records
146
Agent score
75%

What's inside rig

  1. Overview of rig features

    main

    rig is an R Installation Manager that allows you to install, remove, and configure multiple R versions across macOS, Windows, and Linux.

    Key capabilities include:

    • Version Management: Install multiple R versions and select a default version for the terminal and RStudio.
    • Symbolic Names: Install versions using names like devel, next, release, or oldrel.
    • Quick Links: Run specific versions directly via the terminal using links like R-4.1 or R-4.1.2 (automatically added to your PATH).
    • Platform Specifics:
      • macOS: Includes a menu bar app for interactive version selection and supports switching between x86_64 and arm64 builds.
      • Windows: Automatically installs and sets up appropriate Rtools versions.
    • Environment Configuration: Sets up default CRAN/PPM mirrors, creates user-level package libraries, and installs pak for automatic system requirement installation.
    • Developer Tools: Provides shell auto-complete for zsh and bash on macOS/Linux and supports JSON output for scripting.
  2. Docker container features

    main

    All rig Docker containers include the following features:

    • Pre-installed rig: You can use rig commands to add or remove R versions inside the container.
    • Pre-installed pak: The https://github.com/r-lib/pak package is installed for all R versions.
    • Automatic dependency management: System dependencies are automatically installed via pak.
    • Binary package support: Linux binary packages are automatically installed from the Posit Public Package Manager on supported distributions (Ubuntu, Debian, and OpenSUSE).
    • Architecture support: Available on x86_64 and aarch64.
  3. Understand rig's user package library approach

    main

    Why rig uses a user package library

    rig installs non-base packages into a versioned user package library rather than the system library. This provides several benefits:

    • Permissions: Avoids issues on systems (like Windows and Linux) where the system library is not writeable by regular users.
    • Clean Environments: Ensures tools like R CMD check or revdepcheck run in a clean environment containing only base packages.
    • Persistence: You can delete and reinstall an R installation (e.g., using rig rm) without losing your installed R packages.

    macOS System Library Permissions

    On macOS, rig changes the permissions of the system library to prevent users from accidentally installing packages into the system library instead of the user library.

  4. Override rig repository settings in R

    main
    By default, rig sets specific CRAN mirrors and P3M settings. To ignore these settings and use your own repository configuration, set the repos option in your .Rprofile file.
  5. Permissions for `rig system make-links`

    main

    The permissions required to run rig system make-links depend on the mode in which rig is operating:

    • User mode: No administrator rights are required. Links are created in the user's local binary directory (e.g., ~/.local/bin).
    • Admin mode: You must have an administrator account. On Unix-like systems, you may need to use sudo. If you do not use sudo, rig will prompt you for your password.
  6. Compare rig and RSwitch

    main
    While rig and RSwitch have overlapping functionality, they are distinct tools. They can be used together: changing the default R version in RSwitch will also change it in rig, and vice versa. You can use the rig CLI alongside the RSwitch GUI application simultaneously.
  7. Install rig on Windows

    main

    Installation methods for Windows vary based on your permissions and preferred package manager.

    User install (No administrator rights)

    Use the PowerShell install script to install into %USERPROFILE%\.local. This adds %USERPROFILE%\.local\bin to your user PATH.

    irm https://r-lib.github.io/rig/install.ps1 | iex

    After installation, open a new terminal, switch to user mode, and install R:

    rig system user-mode
    rig add release

    System install

    Download the latest release from GitHub releases and run the installer. You may need to restart your terminal for rig to be added to your PATH.

    Package Managers

    • Scoop:
      scoop bucket add r-bucket https://github.com/cderv/r-bucket.git
      scoop install rig
    • Chocolatey:
      choco install rig
    • WinGet:
      winget install posit.rig
  8. Remove OpenMP flags for older R versions on macOS

    main

    If you are installing R versions 3.6.x or earlier on macOS, you may need to remove the -fopenmp flags from the R configuration to ensure compatibility with Apple's default compilers (instead of CRAN's custom compilers).

    Note: If you use rig add to install R, rig automatically runs this command for you after installation. You only need to run this manually if you are managing an existing R installation that is failing due to OpenMP flags.

    This command is only applicable in system mode (admin mode). It does nothing on Windows, Linux, or when running in user mode.

    sudo rig system no-openmp
  9. Configure shell auto-complete for rig

    main

    The rig installers include completion files for zsh and bash on macOS and Linux.

    • zsh: Completions work automatically out of the box.
    • bash: You must install the bash-completion package (via Homebrew or your Linux distribution) and ensure it is loaded in your .bashrc.
  10. Install rig on Linux

    main

    rig can be installed on Linux via DEB/RPM packages or tarballs.

    Ubuntu and Debian (DEB package)

    Add the rig repository and install the r-rig package:

    `which sudo` curl -L https://rig.r-pkg.org/deb/rig.gpg -o /etc/apt/trusted.gpg.d/rig.gpg
    `which sudo` sh -c 'echo "deb http://rig.r-pkg.org/deb rig main" > /etc/apt/sources.list.d/rig.list
    `which sudo` apt update
    `which sudo` apt install r-rig

    RHEL, Fedora, Rocky Linux, Almalinux (RPM package)

    `which sudo` yum install -y https://github.com/r-lib/rig/releases/download/latest/r-rig-latest-1.$(arch).rpm

    OpenSUSE and SLES (RPM package)

    `which sudo` zypper install -y --allow-unsigned-rpm https://github.com/r-lib/rig/releases/download/latest/r-rig-latest-1.$(arch).rpm

    Any Linux distribution (tarball)

    Uncompress the tarball to /usr/local:

    curl -Ls https://github.com/r-lib/rig/releases/download/latest/rig-linux-$(arch)-latest.tar.gz | `which sudo` tar xz -C /usr/local
  11. Manage R projects with rig proj

    main

    The rig proj command set allows you to manage R projects by resolving dependencies declared in a package manifest (typically a DESCRIPTION file). rig resolves these dependencies against configured repositories and can install them into a project-specific library.

    Note: This feature is currently experimental and its interface may change in future versions.