Wednesday 17 April 2013

Installing RStudio Server on Fedora 18

I'm trying to install RStudio Server on Fedora 18 (64bit) but keep getting an error about libcrypto.so.6 and libssl.so.6. (I didn't enable EPEL as I am not on RedHat/CentOS).

Following the installation instructions, I:

wget http://download2.rstudio.org/rstudio-server-0.97.336-x86_64.rpm
sudo yum install --nogpgcheck rstudio-server-0.97.336-x86_64.rpm

But I get the error:

Error: Package: rstudio-server-0.97.336-1.x86_64 (/rstudio-server-0.97.336-x86_64)
           Requires: libcrypto.so.6()(64bit)
Error: Package: rstudio-server-0.97.336-1.x86_64 (/rstudio-server-0.97.336-x86_64)
           Requires: libssl.so.6()(64bit)

If I look in /usr/lib64 I have (both from the openssl-libs package: yum provides /usr/lib64/libssl.so.10):

/usr/lib64/libcrypto.so.10
/usr/lib64/libssl.so.10

So it appears my package versions are too new for RStudio Server (!).

I decided to try the hacky solution of making some links from the old version to the new (hoping that they are backwards-compatible):

sudo ln -s /usr/lib64/libcrypto.so.10 /usr/lib64/libcrypto.so.6
sudo ln -s /usr/lib64/libssl.so.10 /usr/lib64/libssl.so.6

Now I attempt to install again, and use rpm --nodeps instead of yum to force installation:

sudo rpm -ivh --nodeps rstudio-server-0.97.336-x86_64.rpm

It works!

Preparing...                          ################################# [100%]
Updating / installing...
   1:rstudio-server-0.97.336-1        ################################# [100%]
rsession: no process found
Stopping rstudio-server (via systemctl):                   [  OK  ]
Starting rstudio-server (via systemctl):                   [  OK  ]

(Note - if it's still complaining to you about not finding libraries, try

sudo ldd /usr/lib/rstudio-server/bin/rserver | grep 'not found'

You might get something like:

libssl.so.6 => not found
libcrypto.so.6 => not found

This will tell you which libraries you need to make links for.)

I can test whether it worked OK by opening a browser and pointing it to http://127.0.0.1:8787:

Huzzah! RStudio Server!

To enable external access I had to open port 8787 for my firewall (you could use the firewall applet for this instead of command-line)

iptables -A INPUT -p tcp --dport 8787 -j ACCEPT

Now I can continue with the rest of the instructions! Yay!

Tuesday 16 April 2013

Getting RStudio to include your `R_LIBS_USER` in its library paths.

I recently installed RStudio Desktop version on my Linux computer, as I wanted to test it out. Previously I'd been happily using R from the command-line.

However, it kept complaining that I didn't have the knitr package installed.

Starting R from the command-line, I found that I did have knitr installed - library(knitr) worked fine! But library(knitr) from RStudio gave the errror:

Error in library(knitr) : there is no package called ‘knitr’

Upon further inspection, I realised that my package library paths were between R-command-line and RStudio, despite the R executable being identical between the two.

My usual R library for command-line R is ~/R/library, and this was in the .libPaths() as expected (executed from R from the command line).

However, when I executed .libPaths() from RStudio, I got:

[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"
[3] "/usr/lib/R/library"            "/usr/lib/rstudio/R/library"

So why did the same R binary produce different library paths?

It turns out that I set my default path ~/R/library by setting my R_LIBS_USER environment variable in my .bashrc file:

export R_LIBS_USER=$HOME/R/library

but RStudio was not reading my .bashrc file when it started up (makes sense I guess, as it's not running from the terminal).

The solution was to create a file ~/.Renviron and set the R_LIBS_USER variable there. R looks for this file upon starting up to set environment variables (see also ?Startup):

R_LIBS_USER=~/R/library

(Note - I could also just do .libPaths(c('~/R/library', .libPaths()) in an .Rprofile file, but I don't use those in general).

Now I start up RStudio and hey presto! It all works.

Thanks to the folk at StackOverflow, in particular flodel and Dirk EddelBuettel, who helped me work this out (the question has probably been deleted since then as it was too localized and probably should have been asked at the RStudio support page).