How to Install R on Linux Mint 22 and 21

Install R on Linux Mint 22 and 21 with APT or CRAN. Covers r2u binary packages, optional RStudio use, updates, removal, and troubleshooting.

Last updatedAuthorJoshua JamesRead time7 minGuide typeLinux MintDiscussion6 comments

R is the programming language many Linux Mint workstations use for statistics, data visualization, and reproducible research, but the package source controls how current the runtime stays. Install R on Linux Mint from the default repositories when you want the release-matched package, or use CRAN when you need the current stable build from the official Linux download source.

Linux Mint 22.x and 21.x both package R already, while the official CRAN Ubuntu repository provides a newer APT-managed R build for both supported Mint series. Both routes keep R and Rscript in your PATH, and the workflow also covers a personal package library, APT-managed CRAN packages, optional RStudio use, troubleshooting, and removal.

Install R on Linux Mint

MethodChannelLinux Mint 22.xLinux Mint 21.xBest For
Linux Mint repositoriesUbuntu Universe packagesR 4.3.3R 4.1.2Simplest supported install with no extra repository setup
Official CRAN repositoryCRAN Ubuntu repositoryCurrent CRAN R buildCurrent CRAN R buildNewest stable R build and the official Linux download path

Install R from Linux Mint repositories

Start here when you want the stable R package that matches the current Linux Mint base. APT installs the R console and Rscript through the r-base metapackage.

sudo apt update

These commands use sudo for tasks that need root privileges. If this Mint account still needs admin rights, add a new user to sudoers on Linux Mint first.

Install the r-base package after the metadata refresh finishes. The -y flag accepts APT’s confirmation prompt automatically.

sudo apt install -y r-base

Verify the installed package version after APT finishes:

dpkg-query -W -f='${Package} ${Version}\n' r-base

Linux Mint 22.x relevant output includes:

r-base 4.3.3-2build2

Linux Mint 21.x relevant output includes:

r-base 4.1.2-1ubuntu2

This repository install also provides the R console and the Rscript command-line runner.

Install R from the official CRAN repository on Linux Mint

Choose this route when you want the current stable R build from CRAN. CRAN’s Linux download page for Ubuntu-based systems is an APT repository workflow, not a Mint-specific standalone installer, so Linux Mint must use the matching Ubuntu base codename in the repository file instead of the Mint codename.

Linux Mint seriesCRAN suiter2u suite
22.xnoble-cran40/noble
21.xjammy-cran40/jammy

Install the helper packages first, then use the curl command in Linux to fetch the CRAN signing key.

sudo apt install -y ca-certificates curl gpg

Download the CRAN key and convert it to the binary keyring format APT expects. The --yes flag keeps reruns non-interactive by letting gpg replace the existing keyring file.

curl -fsSL https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo gpg --dearmor --yes -o /usr/share/keyrings/cran.gpg

Check the fingerprint before trusting the repository:

gpg --quiet --show-keys --with-fingerprint /usr/share/keyrings/cran.gpg

Relevant output includes:

pub   rsa2048 2010-10-19 [SCA] [expires: 2027-09-30]
      E298 A3A8 25C0 D65D FD57  CBB6 5171 6619 E084 DAB9
uid                      Michael Rutter <marutter@gmail.com>

Create the DEB822 source file that matches your Linux Mint base. This uses sudo tee because a normal > redirection would still try to open the destination file as your regular user.

Linux Mint 22.x uses the Ubuntu 24.04 base:

printf '%s\n' \
'Types: deb' \
'URIs: https://cloud.r-project.org/bin/linux/ubuntu/' \
'Suites: noble-cran40/' \
'Components:' \
'Signed-By: /usr/share/keyrings/cran.gpg' | sudo tee /etc/apt/sources.list.d/cran.sources >/dev/null

Linux Mint 21.x uses the Ubuntu 22.04 base:

printf '%s\n' \
'Types: deb' \
'URIs: https://cloud.r-project.org/bin/linux/ubuntu/' \
'Suites: jammy-cran40/' \
'Components:' \
'Signed-By: /usr/share/keyrings/cran.gpg' | sudo tee /etc/apt/sources.list.d/cran.sources >/dev/null

Refresh APT metadata and confirm that the CRAN package is the candidate:

sudo apt update
apt-cache policy r-base

Linux Mint 22.x relevant output includes:

r-base:
  Installed: (none)
  Candidate: 4.6.0-4.2404.0

Linux Mint 21.x relevant output includes:

r-base:
  Installed: (none)
  Candidate: 4.6.0-4.2204.0

Install the current CRAN build once the candidate version looks correct:

sudo apt install -y r-base

Verify the installed package version after the CRAN install completes:

dpkg-query -W -f='${Package} ${Version}\n' r-base

Linux Mint 22.x relevant output includes:

r-base 4.6.0-4.2404.0

Linux Mint 21.x relevant output includes:

r-base 4.6.0-4.2204.0

Install optional R development packages on Linux Mint

Add the development packages when you expect to compile CRAN extensions locally or you want the broader recommended package set on the same system.

sudo apt install -y r-base-dev r-recommended libssl-dev libcurl4-openssl-dev libxml2-dev

This brings in R headers plus common SSL, curl, and XML development libraries used by packages such as openssl, curl, and xml2. If you want the broader compiler toolchain ready for native extensions, install the GCC toolchain on Linux Mint as well.

Manage R packages on Linux Mint

Once R itself is installed, the remaining choice is where extra packages live and whether APT binaries or source builds make more sense for your workflow.

Create your personal R library on Linux Mint

On a fresh install, R_LIBS_USER can already point at a path under $HOME/R even though that directory does not exist yet. Creating it first avoids the common 'lib = "/usr/local/lib/R/site-library"' is not writable failure.

Rscript -e 'dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE, showWarnings = FALSE)'

Print the resolved library path if you want to confirm where future user-installed packages will land:

Rscript -e 'cat(Sys.getenv("R_LIBS_USER"), "\n")'

The printed path ends with the active R major and minor version, such as .../4.6 on the current CRAN branch. Once that directory exists, install.packages() uses it before the system library paths.

Install CRAN packages from the R console on Linux Mint

Launch the R console as your normal user when you want packages stored in the personal library you just created.

R

Install packages from CRAN from inside that console:

install.packages(c("ggplot2", "tidyr"))

Use RStudio Desktop with R on Linux Mint

You do not need RStudio to use R on Linux Mint. The base install already provides the R console and Rscript, while RStudio Desktop is an optional IDE for scripts, package panes, plots, and notebooks.

Install R first, then download RStudio Desktop from the official Posit page if you want the graphical IDE. Keep that desktop package separate from the R runtime because Posit owns the RStudio installer, updates, and removal path.

Update R and installed packages on Linux Mint

APT keeps the R runtime current, while user-installed CRAN packages update from inside R or through Rscript.

sudo apt update && sudo apt upgrade

Refresh packages in the personal R library with a separate command:

Rscript -e 'update.packages(ask = FALSE)'

Install system-wide R packages with APT on Linux Mint

APT-installed R packages are available to every local user and keep their system-library dependencies under package-manager control.

sudo apt install -y r-cran-dplyr

Use r2u for prebuilt R packages on Linux Mint

The r2u CRAN-Apt project is the practical choice when you want large CRAN stacks as APT binaries instead of compiling them locally. Use r2u after the CRAN repository method above, because current r2u packages depend on the current CRAN R base packages rather than the older default Mint repository build.

Install the helper packages first so the r2u key import works on the same system that already has the CRAN R source configured.

sudo apt install -y ca-certificates curl gpg

Import the r2u signing key next. The published fingerprint is AE89 DB0E E10E 60C0 1100 A8F2 A148 9FE2 AB99 A21A.

curl -fsSL https://eddelbuettel.github.io/r2u/assets/dirk_eddelbuettel_key.asc | sudo gpg --dearmor --yes -o /usr/share/keyrings/cranapt.gpg

Check the saved keyring before trusting the r2u source:

gpg --quiet --show-keys --with-fingerprint /usr/share/keyrings/cranapt.gpg

Relevant output includes:

pub   rsa4096 2014-04-04 [SC]
      AE89 DB0E E10E 60C0 1100  A8F2 A148 9FE2 AB99 A21A
uid                      Dirk Eddelbuettel <edd@debian.org>

Linux Mint 22.x uses the Ubuntu 24.04 base for the r2u source file:

printf '%s\n' \
'Types: deb' \
'URIs: https://r2u.stat.illinois.edu/ubuntu' \
'Suites: noble' \
'Components: main' \
'Signed-By: /usr/share/keyrings/cranapt.gpg' | sudo tee /etc/apt/sources.list.d/cranapt.sources >/dev/null

Linux Mint 21.x uses the Ubuntu 22.04 base for the same file:

printf '%s\n' \
'Types: deb' \
'URIs: https://r2u.stat.illinois.edu/ubuntu' \
'Suites: jammy' \
'Components: main' \
'Signed-By: /usr/share/keyrings/cranapt.gpg' | sudo tee /etc/apt/sources.list.d/cranapt.sources >/dev/null

Add the APT pin next. Linux Mint 22.x needs this because the stock Ubuntu r-cran-* packages can stay visible without becoming the selected candidate. The pin targets r2u’s R package families rather than every package from the repository.

printf '%s\n' \
'Package: r-cran-* r-bioc-*' \
'Pin: release o=CRAN-Apt Project' \
'Pin: release l=CRAN-Apt Packages' \
'Pin-Priority: 700' | sudo tee /etc/apt/preferences.d/99cranapt >/dev/null

Refresh APT metadata and verify that an r2u package really becomes the candidate:

sudo apt update
apt-cache policy r-cran-tidyverse

Linux Mint 22.x relevant output includes:

r-cran-tidyverse:
  Installed: (none)
  Candidate: 2.0.0-1.ca2404.1

Linux Mint 21.x relevant output includes:

r-cran-tidyverse:
  Installed: (none)
  Candidate: 2.0.0-1.ca2204.1

Install a prebuilt CRAN stack once the candidate version is correct:

sudo apt install -y r-cran-tidyverse

Confirm the package version from R afterward:

Rscript -e 'cat(as.character(packageVersion("tidyverse")), "\n")'
2.0.0

Troubleshoot R on Linux Mint

Most R install issues on Linux Mint come from the user library path, the Ubuntu base codename inside repository files, older PPA instructions, or missing build dependencies for source packages.

Fix ‘lib is not writable’ when R install.packages() fails on Linux Mint

Create the personal library directory first, then print the library search path so you can confirm that R now sees the user-owned location before the system directories.

Rscript -e 'dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE, showWarnings = FALSE)'
Rscript -e 'print(.libPaths())'

Rerun install.packages() as your normal user after that. You should not need sudo for packages that belong in the personal library.

Fix wrong Ubuntu codenames in CRAN and r2u sources on Linux Mint

If apt update says a repository has no Release file, inspect the suite lines in the R source files next.

grep -R '^Suites:' /etc/apt/sources.list.d/cran*.sources

Linux Mint 22.x must use noble-cran40/ for CRAN and noble for r2u. Linux Mint 21.x must use jammy-cran40/ for CRAN and jammy for r2u.

Fix c2d4u PPA errors on Linux Mint 22

Older R setup notes sometimes used ppa:c2d4u.team/c2d4u4.0+ for prebuilt R packages. That PPA does not publish a noble suite, so Linux Mint 22.x can stop with Cannot add PPA: This PPA does not support noble. Use the CRAN repository for the R runtime and the r2u workflow for prebuilt r-cran-* packages instead.

Fix R package compilation failures on Linux Mint

Source builds usually fail because the R headers or system development libraries are missing.

sudo apt install -y r-base-dev libssl-dev libcurl4-openssl-dev libxml2-dev

If you want to avoid local source builds for large package sets, switch to the r2u workflow so APT installs prebuilt binaries instead.

Remove R from Linux Mint

Remove the runtime first, then clean up any repository files you added, and only delete the per-user library if you are done with every package stored under $HOME/R.

Remove R packages from Linux Mint

Start with the base runtime packages. Add any system-wide r-cran-* packages you installed to the same removal step or remove them separately afterward.

sudo apt remove r-base r-base-dev r-recommended

If you used APT for extra CRAN packages, remove those package names too:

sudo apt remove r-cran-tidyverse r-cran-dplyr

Clean unused dependencies only after you review the package list APT proposes:

sudo apt autoremove

Remove CRAN and r2u repository files on Linux Mint

Delete only the repository files you actually created for this setup, then remove each keyring only when no remaining APT source still references it. Refresh APT metadata afterward so those sources disappear from future package lookups.

sudo rm -f /etc/apt/sources.list.d/cran.sources /etc/apt/sources.list.d/cranapt.sources /etc/apt/preferences.d/99cranapt

source_paths=()
[ -f /etc/apt/sources.list ] && source_paths+=(/etc/apt/sources.list)
[ -d /etc/apt/sources.list.d ] && source_paths+=(/etc/apt/sources.list.d)

for keyring in /usr/share/keyrings/cran.gpg /usr/share/keyrings/cranapt.gpg; do
    if [ "${#source_paths[@]}" -eq 0 ] || ! sudo grep -R --include='*.list' --include='*.sources' -Fq "$keyring" "${source_paths[@]}"; then
        sudo rm -f "$keyring"
    fi
done

sudo apt update

Remove personal R libraries on Linux Mint

List the user-library directories first so you only delete real R package paths from the current account.

find "$HOME/R" -maxdepth 3 -type d 2>/dev/null

Delete the directory only when you no longer need any of those user-installed packages:

Deleting $HOME/R permanently removes user-installed R packages for the current account. Back up anything you still need from that library path before running the cleanup command.

rm -rf "$HOME/R"

If the find command prints nothing, there is no per-user R library left to remove for that account.

Conclusion

R is ready on Linux Mint from either the release-matched repository build or the newer CRAN package, and the library setup keeps user installs separate from system-wide APT packages. For a fuller development workstation, install GCC on Linux Mint, install Git on Linux Mint, and install VS Code on Linux Mint.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee

6 thoughts on “How to Install R on Linux Mint 22 and 21”

  1. The installation guide is perfect. Thank you very much indeed. It works well. In adding a ppa repo, though,
    ” sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+” does not work on Linux Mint 22. It displays the message
    “Cannot add PPA: ”This PPA does not support noble”.

    Reply
    • Sorry for the late reply, DSerib. You were right about Linux Mint 22: the old ppa:c2d4u.team/c2d4u4.0+ path did not publish a noble suite, so add-apt-repository rejected it. The article has since moved away from that PPA. For Mint 22, use the official CRAN repository for the R runtime and the r2u repository if you want prebuilt r-cran-* packages through APT. I also added a note for readers who hit the old c2d4u/Noble error.

      Reply
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: