Installing RStudio on Mageia 2.0

I recently read an article wherein a developer at Kickstarter talked about using R in the cloud on a machine with 32GB RAM for analyzing different kinds of data. He argued that R works fastest when it can load ALL the data in RAM. At some point he mentioned his IDE was RStudio. Since I had never heard of this software before, I decided to take a quick look. On the RStudio website it claimed RStudio is open source and free. Great! So I clicked on Learn More and that is when I got a thrill. Apparently, you could run the IDE on a webserver. They called this the 'server' version of the IDE. This means you can literally analyze your data on the from any desktop in the world. Heck, even an iPad might be good enough. I needed no further prompting and I went to download it.

Not unexpectedly, it turned out that there was a .rpm of the latest build (v0.97). I downloaded it and tried to install it using `rpm -ivh'. Expectedly, it complained about missing dependencies. I opened drakconf and searched for rstudio from the repositories. No luck. So back to resolving the dependencies. I installed openssl and boost because they were two of the four libraries. For the other two, even pbone was not helpful. Unfortunately, even for boost and openssl, the versions in the repositories are older than what rstudio v0.97 required. Clearly Mageia does not live on the bleeding edge. So now what? It turned out that the website does not provide .rpms for older versions of the software. So back to the same old technique---compile the source code. I had to install gcc (this was a new Mageia server system), cmake, make, ant and of course R-base. With drakconf, this was quick and painless.

Although I should have expected it, it became apparent that the rstudio source code obviously needed the newest version of the libraries. So clearly installing the latest version was not tenable. Could an older version work? Luckily, since rstudio is an open source project, the entire source tree is hosted online at GitHub. So I chose a slightly older version (0.96) and download the .zip file. Unzipped it and as root performed the following steps. First, as per the install file, tried to run cmake. So,

[root@localhost ]# unzip
[root@localhost ]# cd rstudio-0.96; mkdir build; cd build
[root@localhost ]# cmake .. -DRSTUDIO_TARGET=Server -DCMAKE_BUILD_TYPE=Release

This gave an error about missing packages. Not a problem! Install the headers for openssl and pango

[root@localhost ]# urpmi openssl-devel; urpmi pango-devel
[root@localhost ]# cmake .. -DRSTUDIO_TARGET=Server -DCMAKE_BUILD_TYPE=Release

Now it complained about some missing local rstudio dependencies. So first we changed to the rstudio-0.96/dependencies/linux directory. Executing the install-dependencies-yum obviously fails. So we read the file to figure out what's going on. Turns out it tries to install some packages using yum. In theory, substituting 'yum' with 'urpmi' should work but I did not try it. I installed the dependencies manually.

[root@localhost ]# urpmi rpmdevtools libuuid-devel bzip2-devel pam-devel
[root@localhost ]# cd ../common; ./install-gwt; ./install-dictionaries; ./install-mathjax; ./install-boost

Now we try to run cmake again

[root@localhost ]# cd ../../build; cmake .. -DRSTUDIO_TARGET=Server -DCMAKE_BUILD_TYPE=Release

Whew! It went through fine! Homestretch!

[root@localhost ]# make install
[root@localhost ]# useradd -r rstudio-server
[root@localhost ]# cp ../src/cpp/server/extras/pam/rstudio /etc/pam.d/
[root@localhost ]# cp ../src/cpp/server/extras/init.d/redhat/ /etc/init.d/rstudio-server

This file needs to be edited to substitute the correct value for a variable. The default value of this variable (unless you changed it when running cmake is specified in the rstudio INSTALL file.
[root@localhost ]# vi /etc/init.d/rstudio-server
Replace $CMAKE_INSTALL_PREFIX with /usr/local/lib/rstudio and execute the following

[root@localhost ]# cd /etc/init.d; chkconfig --add rstudio-server
[root@localhost ]# ln -f -s /usr/local/lib/rstudio-server/bin/rstudio-server /usr/sbin/rstudio-server
[root@localhost ]# service rstudio-server start

DONE! By default, the rstudio listens on TCP port 8787. You should be able to point your browser to http://localhost:8787/ and login using your system's username and password.