Search code examples
rlinuxubunturstudio-server

Directory Issue, can't install RStudio Server Packages Ubuntu


I set up an Ubuntu VM and can't install packages.

Installing package into ‘/home/username/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)

It looks like all default packages are saved in /usr/lib/R/library

But and RStudio is trying to write new packages into /home/username/R/x86_64-pc-linux-gnu-library/3.0

.libPaths()
[1] "/home/username/R/x86_64-pc-linux-gnu-library/3.0" "/usr/local/lib/R/site-library"                       
[3] "/usr/lib/R/site-library"                              "/usr/lib/R/library"    

I also tried to upload the packages directly to /usr/lib/R/library through FileZilla but I'm getting the following error messages

mkdir /usr/lib/R/library/jsonlite: permission denied

How can I install the packages I need?


Solution

  • After investing the issue further today, I was able to solve it. The problem was due to an outdated version of R, and missing libraries (curl, xml).

    the $ sudo apt-get install r-base command installs whatever version is available on the server.

    Therefore it's important to get the latest version

    sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
    

    I reinstalled R following this tutorial in case anyone runs into the same issue. Setting Up R Studio Server On Microsoft Azure

    Hope this is helpful