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 ~/R/x86_64-redhat-linux-gnu-library/3.3 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 #include
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/ R-core-3.3.2-3.fc25.x86_64
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:
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.