R 3.4.1 "Single Candle" Personal Library Path Error: unable to create ‘NA’
I don't know what's causing this problem (i'm also experiencing it on Ubuntu 16.04), but here's a quick workaround:
.libPaths(c("/home/your_username/R/x86_64-pc-linux-gnu-library/3.4/", .libPaths()))
Of course, you can replace "/home/your_username/..."
for any another directory (that will store your personal library).
This solution makes install.packages()
and library()
work. Waiting for a full fix!
EDIT: I should note that this solution is not persistent. That is, it won't last after restarting R. You can fix this by adding the same line of code described above to the /home/your_username/.Rprofile
file.
Looking at the details in @Dirk 's comment (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866768) this is a planned behaviour so that packages are installed once for all users of the system.
The solution is to make /usr/local/lib/R/
writable for all users, rather than to re-instate the old behaviour of having a personal package library for every individual user.
Open up a terminal and:
- Navigate to
/usr/local/lib/
withcd /usr/local/lib/
- Change the owner:group so that all users can write to the folder. I happen to have a group on my computer that all users are a member of, so I used that, but see https://askubuntu.com/questions/66718/how-to-manage-users-and-groups for help with setting up a group if necessary
- To change ownership use
sudo chown owner:group -R R/
.owner
is an any user, it doesn't really matter.group
is the key one; make sure anyone wanting to use R on your system is a member of this group.-R
is recursive (i.e. do it to all files and folders inR/
). - If you need to change group permissions, use
chmod -R 775 R/
. This gives the owner and group read, write, and execute permissions, and gives all others read and execute permissions.
Now restart R and you should be able to install packages to your this shared location.
My solution was the following:
In the file /usr/lib/R/etc/Renviron
there is a configuration of R.
In lines 43-45 there is:
# edd Jun 2017 Comment-out R_LIBS_USER#R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}##R_LIBS_USER=${R_LIBS_USER-'~/Library/R/3.4/library'}
I have uncommented R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}
, restarted RStudio and now it works.
EDIT: Looking at the comments, it seems like a planned behaviour. Here is another solution.