I am just getting started with Ubuntu and want to program in R. I successfully installed the latest version of R (currently 2.12.2) from the terminal. I then attempted to run the following command:
> install.packages("XML")
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("XML") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to create a personal library
'~/R/i686-pc-linux-gnu-library/2.12'
to install packages into? (y/n)
Should I create the personal directory or did I miss a step somewhere that allows me to write to the site library.
Thanks in advance.
The comment by sarnold
is quite correct. In the Debian (and hence Ubuntu) package, the directory /usr/local/lib/R/site-library/
is created by the file /var/lib/dpkg/info/r-base-core.postinst
script -- and the relevant code is:
# edd 03 Apr 2003 cf Section 10.1.2 of Debian Policy
if [ ! -e /usr/local/lib/R ]; then
if mkdir /usr/local/lib/R 2>/dev/null; then
chown root:staff /usr/local/lib/R
chmod 2775 /usr/local/lib/R
fi
fi
if [ ! -e /usr/local/lib/R/site-library ]; then
if mkdir /usr/local/lib/R/site-library 2>/dev/null; then
chown root:staff /usr/local/lib/R/site-library
chmod 2775 /usr/local/lib/R/site-library
fi
fi
so the directory is owned by root:staff
and of mode 2775, or 'user and group read-write, others read-only'.
So to write there, you have two basic choices:
Always use sudo
or become root
which is clumsy.
Add yourself to the group staff
. There is probably a user-friendly GUI for it; I am Unix old-school and do that by hand by editing /etc/group
and /etc/gshadow
-- after that you can install directly (well you need a fresh shell to have those rights, or just start a new terminal). You can of course also pick a different group, or create one, but then you need to also alter the directory tree in /usr/local/lib/R/
accordingly.
Hope this helps. The r-sig-debian list is a friendly place for Debian/Ubuntu questions like this and I recommend it. The question has come up there before.
Edit: Also, a fair number of (more complicated) packages are part of Ubuntu / Debian, so to get XML you can just to sudo apt-get install r-cran-xml
. Do an apt-cache search r-cran
to see what is available.
The simplest option is to add yourself to the staff
user group. Just run:
sudo adduser <user> staff
Replace <user>
with your username.
Tested in Ubuntu 14.04
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With