RStudio packages on Linux Ubuntu 24.04LTS Pro - A Battle

Hello, I'm having trouble installing packages in RStudio on Linux/Ubuntu.
The first time, everything went smoothly with the installation of R, RStudio, and then the packages. Everything went well without any major issues.
I had to reinstall everything (Ubuntu include) again on the same laptop. I've followed the instructions and install R and RStudio without any issues.
However, installing the packages has been an grueling task, and so far, some packagesβ€”even those from Posit (such as Tidyverse)β€”simply cannot be installed.
I removed everything (R+Rstudio) and reinstalled it again. Same problem.
The repository's path is OK.
From what I’ve gathered, the problem persists because of binary files or files that need to be compiled by RStudio. To be honest, I don’t understand it.
Has something changed in the package installation process that I'm not aware of?
It used to work fine, I would install the dependencies when needed, and the workflow would continue. Now it doesn’t anymore.
Any help would be appreciated.
Thank you.

Hi !

If I understood you correctly, you reinstalled Ubuntu and after the reinstallation the package installation did not work, right? This is probably due to missing developer system libraries that CRAN needs for package installation. I would suggest to manually install the developer tools using

sudo apt install ...

in your terminal.

Another suggestion from my side would be to install the build-in ubuntu packages. What happens if you run

sudo apt update
sudo apt install r-cran-tidyverse

in your terminal?

Hi, yes that is it.
I've tried this using terminal but another errors happens.
It's strange missing libraries because all the installation was right. The first package (or group of packages) that I've tried was Tidyverse and returns 50+ messages or "...output non zero" and did not install it. I've force one package at once ggplot2, dplyr, etc and nothing happened.
Thank you.

Can you show the error? Otherwise it is hard to exactly identify the issue.

Some of your R libraries may require system packages (not installable by R) to work. As one example, the "curl" R library requires the "libcurl4-openssl-dev" system library.

It's a bit tedious, but if you look through the litany of installation messages you may find suggestions for libraries to install (typically one for RPM systems, one for DEB systems). If you install those and retry (iteratively, since installation of library x will fail if it is attempted before prerequisite library y is intalled), eventually you should be good to go.

2 Likes

There are several approaches for managing R and package installations, it might help others to help you if you could share more details about your approach .

To set up an Ubuntu-based workstation, I'd probably opt for rig (installing on Linux), which by default also sets up pak (as an install.packages() alternative) and configures it to use P3M for binary packages.

pak's support for system requirements is supper-handy, depending on how you run R and how have you configured sudo, it can either list all requirements or installs those for your.

Works like a charm in Ubuntu 22.04LTS running in WSL2:

> pak::pkg_install("sf")

β†’ Will install 10 packages.
β†’ Will download 10 packages with unknown size.
+ classInt   0.4-11 [dl]
+ DBI        1.3.0  [dl]
+ e1071      1.7-17 [dl]
+ magrittr   2.0.4  [dl]
+ proxy      0.4-29 [dl]
+ Rcpp       1.1.1  [dl]
+ s2         1.1.9  [dl] + βœ– libabsl-dev, βœ– cmake, βœ– libssl-dev
+ sf         1.1-0  [dl] + βœ– libgdal-dev, βœ– gdal-bin, βœ– libgeos-dev, βœ– libproj-dev, βœ– libsqlite3-dev
+ units      1.0-1  [dl] + βœ– libudunits2-dev
+ wk         0.9.5  [dl]
βœ– Missing 9 system packages. You'll probably need to install them manually:
+ cmake            - s2
+ gdal-bin         - sf
+ libabsl-dev      - s2
+ libgdal-dev      - sf
+ libgeos-dev      - sf
+ libproj-dev      - sf
+ libsqlite3-dev   - sf
+ libssl-dev       - s2
+ libudunits2-dev  - units

> pak::pkg_sysreqs("sf")
── Install scripts ─────────────────────────────────────────────────────────────────────────────────────────── Ubuntu 22.04 ──
apt-get -y update
apt-get -y install libabsl-dev cmake libssl-dev libgdal-dev gdal-bin libgeos-dev libproj-dev libsqlite3-dev libudunits2-dev

── Packages and their system dependencies ────────────────────────────────────────────────────────────────────────────────────
s2    – cmake, libabsl-dev, libssl-dev
sf    – gdal-bin, libgdal-dev, libgeos-dev, libproj-dev, libsqlite3-dev
units – libudunits2-dev

Just note that rig uses R builds from rstudio/r-builds, not official CRAN builds.

1 Like

I also had an issue with package installation on windows because of runtime errors. I had suggestions from Posit AI to install the tidyverse metapackages one by one, but still had the same problem. I left it for a while, but after installing an update on the dailybuilds, It was able to properly. Maybe you can install the latest dailybuild, and see what happens. The runtime issue may also be probably also due to network issues.

1 Like

Sorry but I couldn't reproduce. I'm considereing uninstall everything including Ubuntu (maybe Fedora this time) and start again. Thanks.

Hi, yes indeed. I followed the procedure to install everything because it's not my first time doing this. I installed the libraries that are necessary to to that and even so nothing happened.
Thank you and I will follow your instructions next installation.

Hi. Ok I understand your point, but I haven't had problems with windows installation. I prefer Linux but lately I'm having problems that's really annoying. Thanks for reply.

Hi. Thank you for help. I will try your solution.

I run rstudio on Ubuntu and I install packages from the command line as root and have no issues. Sudo r, and then do the installs

1 Like

Ok. but no matter how I tried even on terminal I couldn't install some packages.

Whenever I have had a package installation fail, it has meant that a library (usually a development library) for something is missing. Sometimes the package will recommend which libraries to install. If it doesn't, copy the error message and paste it into google. That will nearly always turn up the answer.

1 Like