The Perfect Setup for Ubuntu and R (and how to install/update RStudio with apt install rstudio/apt update)
Install R packages as you would do on Windows (i.e., no long compilation time). In addition, this script asks to install R development tools, Git, RStudio, and Quarto.
Just to save time for my future self. Hopefully, it can help people in the cyberspace too :)
Just copy and paste this one-line command:
sudo bash -c "$(wget -qO- https://raw.githubusercontent.com/pachadotdev/r-packages-ubuntu/main/configure.sh)"
If you get an error such as E: The repository 'https://apt.pacha.dev ./ InRelease' is not signed.
, please run the configuration script again. It will add the updated public key.
If you are on Ubuntu 22.10 or higher, the script will detect it and exit. This is because the official R sources are not compatible with those versions yet.
The command will ask you to install:
- R
- R development tools (i.e, r-base-dev)
- Git
- RStudio Desktop (stable or daily build)
- Quarto
- BSPM (R's Bridge to System Package Manager)
You can use it on a fresh or existing setup.
When you reopen RStudio after running the script, you'll see an output like this:
> install.packages("devtools")
Available system packages...
There are binary versions available but the source versions are later:
binary source
fs 1.6.1 1.6.2
...
devtools 2.4.3 2.4.5
Do you prefer later versions from sources? (Yes/no/cancel) n
After selecting "n", to install from binaries, R internally communicates with Ubuntu package manager, and installing 'devtools' takes around 10 seconds versus around 5 minutes when building from sources (10 minutes if you need to reinstall because a system dependency was missing).
One advantage of this approach is that it shall satisfy all dependencies (i.e., it will install libpq-dev
when installing RPostgres
).
The script above configures an APT repository to my server pacha.dev, which offers the same stable RStudio version as rstudio.com. The advantage is that when the server is updated and you run apt update
it will offer a newer version that you can install with apt upgrade
.
In other words, the script enables apt install rstudio
.
Yes.
Yes, you can re-trace all the steps I followed here: https://github.com/pachadotdev/r-packages-ubuntu.
Tested from a graphic environment (Cinnamon). I opened a terminal and pasted the command from the instruction at the start of this README.
According to #4, it works. I am awaiting details from @rishieco.
Tested in a Docker container.
From my laptop I run this, but you don't need to install wget
and the rest of dependencies in a "real" Ubuntu 22.10:
~ $ docker run -it ubuntu:22.10
root@c7ed22bee36e:/# apt update && apt install wget software-properties-common gnupg
root@c7ed22bee36e:/# bash -c "$(wget -qO- https://raw.githubusercontent.com/pachadotdev/r-packages-ubuntu/main/configure.sh)"
The test is implicit because Linux Mint 21.1 is based on this version.
Tested in a Docker container.
There is no Release file for kinetic
in the official R sources, so it does not work.
Same reason as 22.10.
On Ubuntu 22.04 Desktop, when you install a package and R asks "Do you prefer later versions from sources? (Yes/no/cancel)" you should select "yes" or it gets stuck. I could not replicate this with Docker See #4.
- Go to the commented PGP part in
01-sync-server.sh
every 180 days to renew the key (done on 2023-06-24) - Update the public key in
configure.sh
because of apt-key deprecation (where it says "Is it ok to add apt.pacha.dev as a source for RStudio and/or Quarto?") - Correct why I must run
01-sync-server.sh
twice to remove the messageW: Skipping acquire of configured file 'Packages' as repository 'https://apt.pacha.dev ./ InRelease' does not seem to provide it (sources.list entry misspelt?)
withapt update
.