[R-sig-Fedora] installing R from source on fedora

Mark Leeds markleeds2 at gmail.com
Wed Nov 9 05:47:13 CET 2011


Hello: I've included a txt file ( some day, when I have more time, I'll
turn it into latex )  that has the steps for installing R from source on
Fedora. It was
written only for people like myself who find these  tasks difficult.

Also, could someone from the R-Sig-Fedora list let me know if the txt file
was attached because I don't actually receive emails that I send to the
R-Sig-Fedora list. ( not sure why this is ? ).   If it doesn't go through,
I'll cut and paste and re-send it in the email itself. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-fedora/attachments/20111108/34ad02ae/attachment.html>
-------------- next part --------------
The following are instructions for installing R from source in Fedora Linux. Note that I deleted the previous version of R and any directories associated with it ( except
for packages pevious downloadedfrom cran. These packages do not need to be deleted as long as they are in a personal and non R build related directory ) in order to  make these 
instructions for installing R from source rather than for upgrading R. Upgrading requires a slightly different set of instructions and will not be discussed here. 

Some of the steps in these instructions may not be exactly required and it is possible that there are alternative ways of achieving the same build. They  only
reflect the way I achieved my build. Many thanks to Gavin Simpson, Marc Schwartz, Pierre-Yves Chibon and Jose Matos for their help in creating these instructions. Most of the 
instructions resulted from various communications between myself and Gavin Simpson. There are what I view as eight steps when installing R on Fedora from source and these are 
described below:

#==========================================================================================================================================================================

Step 1)  Create a directory structure right above your home directory called R/2.14/build by going to your home directory and doing mkdir -p R/2.14/build. The 2.14 directory will 
eventually  contain the R source tree and the build directory will contain the various output once the R source tree is configured and built.
#============================================================================================================================================

Step 2) Go to the build directory by doing cd ~/R/2.14/build and grab the latest source from the svn repository by issuing the command: 

svn checkout https://svn.r-project.org/branches/R-2-14-branch ../

This command will install the R source tree in the ~/R/2.14 directory.

Note that the step above can be modified by grabbing the the latest release from  a cran mirror instead:  Go to www.r-project.org and then one of the cran mirrors. Click on 
the sources icon and download the R.X.tar.gz file to the ~/R/2.14 directory. You can extract the source from the tar.gz fiel by issuing the command t

tar xvfz filename.tar.gz

This will extract the source tree also. But note that this source will not include any of the latest patches that have occurred since that R release. Note that, if svn is used to 
checkout the source tree, then Step 4 below is required. If svn is not used and used and tar is used instead, then Step 4 is not necessary.

Next we need to configure and build R from the source tree and this is where things can get tricky. The reason it can be tricky is because there are many header and development 
files that are required  to be installed on your machine in order for the build to work correctly. 

As far as I know, there are two insurance policies that can be taken out in order to try to insure that all of the headers and development packages are on your machine. 
These policies are described in steps 3A and 3B. I recommend that both policies be used because if 3b) tries to load a dependency that is already installed, it will just stop
with a message that the package is already installed.
#============================================================================================================================================

Step 3A) Use yum or the Fedora software manager and install the following  packages. If they already installed on your machine, you will be notified of
this when you try to install them.

The RPMs that should be installed are listed below.

libX11
libX11-devel
libXt
libXt-devel
readline-devel
cairo-devel
libtiff-devel
libjpeg-turbo-devel
libpng-devel
tk-devel
tcl-devel

Note that it does not matter what directory you are in when installing these packages.  So, for example, if you are using yum, then  do su -c "yum install libX11" to install 
libX11.( Note that su -c simulates that you are logged in as root without you having to actually log in as root ). If instead you want to use the software manager rather
than yum, then click on  System, then Administration then Add/Remove Software and then follow the instructions. They are straightforward.
#============================================================================================================================================

Step 3B) Install the yum-utils package by doing yum install yum-utils. This package contains a program called yum-builddep which builds the dependencies that another software
package needs. Therefore, once yum-utils is installed,  one can issue the command su -c "yum-builddep R" and this should download and install the variious packages that R 
is dependent on. Again it does not matter what directory you are in when you issue this command.

The steps 3A) and 3B) should most likely provide all the header files and development tools that are needed to build R from source. But you won't know until you try it.
#============================================================================================================================================

Step 4) Note that, if R was checked out using svn, then the svn repository does not contain th source files for the Recommended R packages and these need to be downloaded
seperately using rsync. Therefore, if R was checked out from the svn repo, then, while in the ~R/2.14 directory, issue the command

./tools/rsync-recommended

This command will download the sources of the recommended packages like MASS, lattice etc.
#============================================================================================================================================

Step 5) Now we can finally run the configure command. Make sure that you are in the directory ~/R/2.14/build and issue the command 

../configure

The process should complete fairly quickly and the last 10 lines or so of the configure output will indicate whether the configure has run without errors. Hopefully there won't be 
any errors. If there are errors, then , if they are not obvious, the best thing to do is email the R-Sig-Fedora list. There are many generous and knowledgeable people there who 
are glad to help. Assuming there are no errors, then proceed to Step 6. 
#============================================================================================================================================

Step 6) Now we need to build what we configured by issuing the make command. Again  make sure that you are in the directory ~/R/2.14/build and issue the command make at the 
command line. Although the make command will will take a long time to complete, if it goes through completely, that indicates that it worked. If there is an error at any
point during the make, the make process will stop and indicate that an error has occurred and provide a brief description of the error.
#============================================================================================================================================

Step 7) Now, when in the ~/R/2.14/build directory, issue the command make check to verify that everything was built correctly. You should see a lot of "OK" statements and
no "Error" statements.
#============================================================================================================================================

Step 8) Finally, although R has been built successfully,  we still need to set things up so that, no matter what directory we are in on the machine, we can issue the command R from 
that directroy and start an R session. Assuming that R was built correctly, then there should exist a directory called ~/R/2.14/build/bin. In this directory reside many bash 
scripts one of which is called R. R is a bash shell wrapper for the R executable. So, if we can make a link so that, whenever one types R anywhere, this script is run, then 
this will allow us to run R from any directory by typing R.

How to do this :

A) Create a directory called bin under your home directory by issuing the command mkdir ~/bin. Also make sure that this directory is on your path by including it in
the definition of the PATH variable in your .bashrc file.

B) Make a link to the R wrapper in ~R/2.14/build/bin directory by issuing the following command in the bin directory that you made in your home directory: 

ln -s ~/R/2.14/build/bin/R ~/bin/R

This command creates a link so that, whenever you type R anywhere, this will issue the R command in the ~/bin/R directory which is symbolic for the R wrapper in the
/build/bin directory. In this manner, whenever R is typed at the command line of any directory, an instance of R will be started.
#============================================================================================================================================

Any mistakes in these instructions are due to me and they are subject to change. Again, thanks to eeveryone who helped me install R from source especially Gavin
Simpson.





































More information about the R-SIG-Fedora mailing list