Installing R Packages in Fedora as a user

When I was trying to run R code that required additional packages, I got the error message:

Installing packages into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
Warning in install.packages(new.pkg, dependencies = TRUE) :
 'lib = "/usr/lib64/R/library"' is not writable

Summary: If you create the following directory then R will install package files in there instead.


Here’s the more detail steps I took.

In order to work around this, I tried running just the install command from an interactive R prompt. In this case, the package was “SuperLearner”

> install.packages("SuperLearner")
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
Warning in install.packages("SuperLearner") :
  'lib = "/usr/lib64/R/library"' is not writable
Would you like to use a personal library instead?  (y/n) y
Would you like to create a personal library
to install packages into?  (y/n) y

After this, a dialog window popped up and had me select a CRAN mirror (I picked the geographical closest one) and it was off and running.

It errored out later with :

bit-ops.c:1:15: fatal error: R.h: No such file or directory

Which looks like I am missing the development libraries for R. I’ll return to this in a bit.

If I exit out of R and check the directory ls ~/R/x86_64-redhat-linux-gnu-library/3.3/ I can now see it is populated.

The Base R install from fedora owns the library directory:

 rpmquery -f /usr/lib64/R/library/Matrix/

And we don’t want to mix the core libraries with user installed libraries. Leet me try a different one, now that the local users libary directory structure has been created:

> install.package(“doRNG”)

Similar error…ok, let’s take care of the compile error.

sudo dnf install R-core-devel

And rerun the install in an R session now completes successfully. I tried on a different machine and had to install the ‘ed’ command line tool first.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.