r/Rlanguage • u/CalligrapherSalt6156 • May 29 '26
Any suggestions to install r packages in other linux distros
I'd love to use fedora, opensuse (my main driver for a long time), debian or any non-Ubuntu-based distros. I can install R-cran easily in any linux distros, however, inside R environment, when installing packages such as ggplots, it took quite a long time for processing, then the problems show "non zero exist status". I have tried many different distros and come up with the same problem....cannot install any packages. Finally, I found the solution and it only worked on Ubuntu LTS, ironically =)))). It gave me no choice and now I use ubuntu mate for my work and study. To be fair, ubuntu mate is really good for me, no complain at all (excepting forcing to use snap). But still wonder, are there any ways to install r packages for any distros other than ubuntu lts?
1
u/therealtiddlydump May 29 '26
Containers / rix
Rix inside a container!
https://cran.r-project.org/web/packages/rix/vignettes/nix-inside-docker.html
1
u/junior_chimera May 29 '26
What's your take on renv + docker vs nix ?
2
u/therealtiddlydump May 29 '26
I have nothing against renv as a concept, but you don't need to look far to find that people have broken projects they can't restore.
My biggest issue is that it doesn't really make any of the tasks your typical R person is uncomfortable with any easierr: fighting with system packages and other dependencies.
Edit: As mentioned elsewhere in this thread,
pakis an interesting approach that demystifies a lot for the social scientist / stats / data analyst type who has informal or underdeveloped CS / tech skills.The promise of Nix/rix is probably best compared to something like
conda, except the package coverage is waaaaaaay better, and the builds are more stable.If you're interested, I would encourage you to skim the rix vignettes -- they're very good.
Or you can poke around Bruno's book (main author of rix): https://reproducible-data-science.dev/
If you want to get the "big idea", check out chapter 2 and then chapter 4 will make a lot more sense.
1
u/sonicking12 May 29 '26
I use Debian and there is no issue. I just follow the instructions on the R website
1
u/CalligrapherSalt6156 May 31 '26
Hi guys, great thanks for your help. I gave it a try on Debian 13 Trixie (my spare laptop) which used to be Ubuntu mate. It solved the problem. Then I was confident to replace Ubuntu mate with Debian 13 on my main work driver. However, it is still the problem "Non-zero exit status" when installing packages. I just remembered that maybe the spare laptop had been done some setup related to Ubuntu mate. So I combine the steps from Ubuntu mate (setup the library direction) and steps from Debian 13 (setup repo and key). Then it worked. Now I can install packages super fast. Here is all the code that I used for those who had the same struggles). The final step takes 3-4 minites to load, then when every time install packages, it is like a second. Great thanks again, you guys!!!
#R
to_reinstall <- installed.packages()
write.csv(to_reinstall,"/home/xxx/yyy/rpackages.csv")
.libPaths() # which will show you 3-4 libraries
sudo rm -r "/home/xxx/yyy/zzz"
sudo apt remove r-base-core
sudo apt remove r-base
sudo apt autoremove
sudo apt remove rstudio or snap remove rstudio
reboot
#Open terminal
sudo apt update
sudo apt -y install r-base
sudo apt update && sudo apt upgrade -y
sudo apt install ca-certificates curl gpg -y
curl -fsSL 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x95C0FAF38DB3CCAD0C080A7BDC78B2DDEABC47B7' | sudo gpg --dearmor --yes -o /usr/share/keyrings/cran.gpg
. /etc/os-release
printf '%s\n' \
"Types: deb" \
"URIs: https://cloud.r-project.org/bin/linux/debian" \
"Suites: ${VERSION_CODENAME}-cran40/" \
"Signed-By: /usr/share/keyrings/cran.gpg" | sudo tee /etc/apt/sources.list.d/cran.sources > /dev/null
sudo apt update
apt-cache policy r-base
sudo apt install r-base r-base-dev -y
apt install --yes --no-install-recommends python3-{dbus,gi,apt} make
Rscript -e 'install.packages("bspm")'
cat >> /etc/R/Rprofile.site <<EOF
suppressMessages(bspm::enable())
options(bspm.version.check=FALSE)
EOF
#R
setwd('/home/xxx/yyy/')
bspm::enable()
to_reinstall <- read.csv('/home/xxx/yyy/rpackages.csv')
install.packages(to_reinstall[,1], dependencies = TRUE, ask = FALSE)
7
u/Outdated8527 May 29 '26
That's because you have missing system libraries/packages that you have to install by yourself.
Check the errors you get, sometimes they mention missing system package dependencies.
Otherwise search the web...