Installing R-devel on Linux (Ubuntu/Mint)

This post has been updated:

  • 30. March 2019: changed library path to 3.7
  • 28. August 2018: added more required software
  • 1. March 2018: Removed `bash ./tools/rsync-recommended` and  `bash ./tools/link-recommended`. They should not be needed anymore.
  • 15. November 2017: Removed installing of recommended packages from build script. Those packages are now simply installed in the local library path which is also added to the `LIB_SITE`. This also allows that checked packages depend on recommended packages and those will also be updated with update.packages().
  • 1. July 2016: Updates thanks to comment of Frederik Eaton
  • 2. April 2016: Included downloading and building recommended package (I couldn’t check packages requiring recommended packages without that).
  • 29. March 2016: Updated script as it stopped working (Thanks to Matt Flor for noticing that).


Before submitting an R package to CRAN the CRAN policies require that a package runs R CMD check --as-cran without any warnings or notes. More specifically, the policies demand that “[t]his should be done with the current version of R-devel”.  Previously I have done this on Windows, but even with the latest R-devel there are always issues that just do not pop up there (e.g., checking of URLs). Consequently, I have recently (finally) switched to Linux. But as a total Linux noob setting up R-devel was not trivial. This post shows how to set up R-devel next to the latest regular R and how to use it to test packages.

To install R-devel you first need to make sure you are able to install R, R-packages, and have a working LaTeX installation (e.g., texlive). Please follow the instructions here:
Alternatively, simply run:

sudo apt-get install texlive-base
sudo apt-get install texinfo
sudo apt-get install texlive-latex-base
sudo apt-get install texlive-latex-extra
sudo apt-get install texlive-fonts-extra
sudo apt-get install texlive-fonts-recommended

Then you will also need subversion (for getting the latest source), I also needed to install xorg (in case you get some unexpected errors it may be necessary to also install the suggestions given here), and some more software listed below:

sudo apt-get install subversion ccache
sudo apt-get install xorg-dev
sudo apt-get install libcurl4-openssl-dev

Now you need to get a current version of the source code via svn (i.e., subversion). For this, first create a folder svn in your home directory, change to this directory, and then checkout the latest version of the source code.

cd ~
mkdir svn
cd svn
svn co r-devel/R

You also need to download and link the recommended packages for using them in R CMD check as described in the R installation manual (this needs to happen in the correct folder).

cd r-devel/R/

Following a comment from Martin Maechler we do not build R in the svn directory, but rather in a newly created build directory:

mkdir ~/svn/R-devel-build

Next you need to build R-devel, preferably in a different location then your usual R installation. We do this with a script courtesy of Dirk Eddelbuettel (which I changed so it uses the correct path). Simply create a new file build-R-devel with the following content. It makes a lot of sense to put this file in a location that is in the $PATH, I recommend /usr/local/bin (which requires root/sudo). At the end of this, we automatically run make install which we also add to the script (which is in contrast to the recommendations of Martin Macheler from above, but it works just fine).

## ~/bin/build-R-devel


cd ~/svn/R-devel-build

R_PAPERSIZE=letter                \
R_BATCHSAVE="--no-save --no-restore"         \
R_BROWSER=xdg-open                \
PAGER=/usr/bin/pager                \
PERL=/usr/bin/perl                \
R_UNZIPCMD=/usr/bin/unzip            \
R_ZIPCMD=/usr/bin/zip                \
R_PRINTCMD=/usr/bin/lpr                \
LIBnn=lib                    \
AWK=/usr/bin/awk                                \
CC="ccache gcc"                    \
CFLAGS="-ggdb -pipe -std=gnu99 -Wall -pedantic" \
CXX="ccache g++"                \
CXXFLAGS="-ggdb -pipe -Wall -pedantic"         \
FC="ccache gfortran"                   \
F77="ccache gfortran"                \
MAKE="make -j4"                    \
../r-devel/R/configure                     \
    --prefix=/usr/local/lib/R-devel         \
    --enable-R-shlib                 \
    --with-blas                 \
    --with-lapack                 \
    --with-readline                 \

#CC="clang -O3"                                  \
#CXX="clang++ -03"                \

#make svnonly

echo "*** Done -- now run 'make install'"

make install

echo "*** All Done -- start R-devel with 'bash R-devel'"

Next, you need to install R-devel using this script which automatically changes to the correct directory. Note that this step requires sudo.

sudo bash build-R-devel

Now we only need a custom run script to actually run R-devel. Again this script is based on one written by Dirk Eddelbuettel and it should also be in a folder which is in the path such as /usr/local/bin. Note that we need to export the local library path for this installation as well. Below this is ~/R/x86_64-pc-linux-gnu-library/3.7, but this might need updating depending on your setup.

## ~/bin/


export R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R-devel/lib/R/library:~/R/x86_64-pc-linux-gnu-library/3.7'}
export PATH="/usr/local/lib/R-devel/bin:$PATH"
R "$@"

To finally run R-devel simply call it as a script: bash R-devel
It should show you that it is the current development version: R Under development (unstable) (CURRENT DATE)
As this is a vanilla version of R, you will have to install all the packages you need.

The R-devel script can also be used to build or check your package:

bash R-devel CMD build your-package-directory
bash R-devel CMD check --as-cran your-package.tar.gz

Once all this is set up, the steps of updating your R-devel installation to the latest version only involves calling the scripts in the right order:

cd ~/svn/r-devel/R
svn update
sudo bash build-R-devel

After doing so, it is probably a good idea to update the packages:

bash R-devel
update.packages(ask=FALSE, checkBuilt = TRUE)

I have used the following sources to compile this post:



  • Thanks for that fantastic guide! That went very smoothly.

    However, I encountered a weird error when installing packages. Some went fine, others threw a object 'checkCompilerOptions' not found error, like here:

    So, to anyone also seeing this: I finally managed to solve the issue after reading
    All I had to do was removing the /usr/lib/R/library path in


    export R_LIBS_SITE=${R_LIBS_SITE-‘/usr/lib/R-devel/lib/R/library:/usr/local/lib/R/site-library:/usr/lib/R/site-library’}
    export PATH=”/usr/local/lib/R-devel/bin:$PATH”
    R “$@”

    Matt Flor2016-03-21
  • Matt, thanks for your comment. I also needed to make this change to get it to work now. I have updated the guide accordingly.

    Henrik Singmann2016-03-29
  • Thanks for this manual! It all worked pretty well

  • Interesting post, thank you!

    you configure –without-recommended-packages, but you first do ./tools/rsync-recommended, why?
    you configure with –prefix=/usr/local/lib/R-devel, but the script to run R points to /usr/lib/R-devel, why?
    Martin Maechler suggested using a “build directory”, see

    Frederick Eaton2016-05-24
    • Hi Frederik,
      Thanks a lot for your comments. I have finally found the time to update the guide accordingly. I also have removed the step to call make install separately and added it to the script.
      Thanks and let me know if you see other problems.

      Henrik Singmann2016-07-01
  • Hi Henrik,

    the rsync stage does not wor on my ubuntu 16.04 distribution. I did the command
    bash ./tools/rsync-recommended

    There is the shell output:
    rsync: failed to connect to ( No route to host (113)
    rsync error: error in socket IO (code 10) at clientserver.c(128) [Receiver=3.1.1]
    *** rsync failed to update Recommended files ***

    Etienne Borocco2016-10-19
    • The error message suggests it is actually a problem with your internet connection. Perhaps it was temporary down or the SVN server unavailable. It still works on my machine.

      Henrik Singmann2016-10-22
  • On the r-help ML, I was told there were issues with the Vienna servers. However, I still got the same output. Can it be a firewall? I am connecting from my university.

    Etienne Borocco2016-10-24
  • Hi Henrik,

    Thank you so much for this tutorial. Here are some issues that I got and how I solved them. It might not be the optimal solution but it worked. I am on ubuntu 14.04 LTS.

    I) Problem of ‘connection time out’ when doing bash ./tools/rsync-recommended

    I have executed these commands instead:

    bash -x ./tools/rsync-recommended
    I took the the version info on the ‘rsync’ line which should output at the end.
    I did: wget -r -l1 –no-parent -A*.gz -nd -P src/library/Recommended

    II) sudo bash build-R-devel: got error ‘/usr/bin/install: cannot stat ‘NEWS.pdf’: No such file or directory’

    going to ~/svn/R-devel-build and typing ‘sudo make’
    got error message: ‘pdflatex’ is needed to make vignettes but is missing on your system.’

    do: ‘sudo apt-get install texlive-latex-base’
    do: ‘sudo apt-get install texlive-latex-extra’
    do: ‘sudo apt-get install texlive-fonts-extra’
    do: ‘sudo apt-get build-dep r-base’
    do: sudo make
    do: sudo make install

    bash R-devel worked.

    Hope this can help.

    (PS: Did you use an online solution to build your website? thanks)

    Nicolas Descostes2017-09-06
    • Hi Nicolas,

      Thanks for your comment. Regarding (I), I haven’t yet encountered this. Good to know there is a solution. Regarding (II), I should probably add texlive to the requirements. Thanks for catching that.

      My website is a simple wordpress website on a commercial server running the pitch premium theme from Site Origin (which is not available any more).

      Henrik Singmann2017-09-07
  • Thanks so much for this post! Works smoothly up to when I run lines 51-58. I get “configure error: in ‘/root/svn/R-devel-build’: configure: error: C compiler cannot create executables’. Do you have any recommendations? I am new to Linux (apparently, my package is not running with Debian) and fairly lost…

  • Ah I also had to run ‘sudo apt-get build-dep r-base’ – seems to work now 🙂

  • Hi Henrik,

    I tried to update the R-devel and I am running through several errors. I do not manage to understand what to look for. I think that the version of R that is loaded is not the correct one but I am not sure. Below are the commands with errors. any idea?

    cd ~/svn/r-devel/R
    svn update
    wget -r -l1 –no-parent -A*.gz -nd -P src/library/Recommended
    bash ./tools/link-recommended
    ln: target ‘MASS.tgz’ is not a directory
    ln: target ‘Matrix.tgz’ is not a directory
    ln: target ‘nlme.tgz’ is not a directory
    ln: target ‘foreign.tgz’ is not a directory
    ln: target ‘rpart.tgz’ is not a directory
    ln: target ‘mgcv.tgz’ is not a directory

    > sudo bash build-R-devel
    *** No rule to make target `../../../r-devel/R/src/nmath/expm1.c', needed by `Makefile'. Stop.

    > bash R-devel
    Error: package or namespace load failed for ‘methods’:
    package ‘methods’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
    ... "and other similar messages"

    Nicolas Descostes2018-02-28
    • Hi Nicolas,

      The error is that the recommended packages you have installed were compiled with a different version of R-devel (e.g., 3.4 when it is now 3.5). The code now suggests to not install them anymore directly with R. I am not really sure how to solve this elegantly. But I think simply reinstalling R-devel (make sure to use the up-to-date code) should work.

      Henrik Singmann2018-03-01
      • Make sure to delete the version of R-devel you are having from disk before reinstalling!

        Henrik Singmann2018-03-01
      • it worked. thank you so much!

        Nicolas Descostes2018-03-02
  • Hi, thank you very much for this awesome guide. It helps a lot.
    I have a very quick question: you write ” Note that we need to export the local library path for this installation as well. Below this is ~/R/x86_64-pc-linux-gnu-library/3.6″ and the script executes “export R_LIBS_SITE=${R_LIBS_SITE-‘/usr/local/lib/R-devel/lib/R/library:~/R/x86_64-pc-linux-gnu-library/3.6’}”.
    Could you please explain what this does exactly and why we do it? As I understood the packages installed for R and R-devel are separate anyhow.
    Thank you very much!

    • I am sure there is a better way for this, but we need to tell R-devel which library path to use. And here I simply use the one for the upcoming R version (which R-devel will turn into, which currently is 3.6). I think if I did not do it, both installed R versions used the same library. And in case, the built for them was different that led to problems. Without this, I definitely had some problems at some point. But if you have a better solution, I would be happy to hear about it. I am also not an expert on these matters.

      Henrik Singmann2019-03-24
  • Hey, thanks for this clear and very helpful guide.
    Everything ran as expected, just when I finally started R-devel and ran .libPaths(), I get

    > .libPaths()
    [1] "/home/steffi/R/x86_64-pc-linux-gnu-library/3.5"
    [2] "/home/steffi/R/x86_64-pc-linux-gnu-library/3.6"
    [3] "/usr/local/lib/R-devel/lib/R/library"

    So it will still look for packages in the library for the release version.
    Any idea why this is still there despite defining the paths in ?

    • Unfortunately, I cannot replicate that. Under the “normal” R I get:
      [1] "/home/henrik/R/x86_64-pc-linux-gnu-library/3.5"
      [2] "/usr/local/lib/R/site-library"
      [3] "/usr/lib/R/site-library"
      [4] "/usr/lib/R/library"

      Under R-devel I get:
      > .libPaths()
      [1] "/home/henrik/R/x86_64-pc-linux-gnu-library/3.6"
      [2] "/usr/local/lib/R-devel/lib/R/library"

      So I guess something needs to be different in your configuration compared to mine.

      And sorry for the slow reply. I only use my Linux for development, so needed some days to boot into it again.

      Henrik Singmann2019-03-30
    • One possibility for the difference is that the current development version is now 3.7 (as 3.6 will be released in the next few weeks). I just noticed this as well and changed the library path in accordingly.

      Henrik Singmann2019-03-30
  • Thank you for this! I was able to run through everything without any errors. However, now I would like to load this developmental version of R in RStudio on an aws server. When I do “which R” I get the path for the development version of R, but when I launch RStudio, the latest release that I have been using is loaded. Do you have any advice?


    Abbe Clark2019-10-28
  • Thank you very much for this very useful tutorial.
    I managed to install R-devel without problems. However, when updating the base packages and installing new ones, everything got confused in my system: some packages were built for R 4.0.0 but their dependencies were build for R 3.6.3.
    How can I specify in the procedure you described above that R-devel and all its packages will be installed in a separated directory of the normal R installation (making clear when to use sudo or not)?

    • If you followed the steps in the post, this should not have happened (and does not on my machine). Note that the install script specifies --without-recommended-packages so those packages are not installed at built time. You have to install them manually. The crucial bit is then in the which specifies the installation path for packages via the R_LIBS_SITE environmental variable.

      You should check the library paths of both of your R versions via .libPaths() to see what they point to. If they point to different directories, there should be no problem.

      Henrik Singmann2020-03-12
  • 2020-06-22

    […] my first approach in which I simply tried to add the –disable-long-double option to the R-devel install script failed. After quite a bit of searching I found the solution on the RStudio community forum thanks […]

  • 2020-06-22

    […] my first approach in which I simply tried to add the –disable-long-double option to the R-devel install script failed. After quite a bit of searching I found the solution on the RStudio community forum thanks […]

  • Hi Henrik.

    I followed all the recommended steps. When I run the command “$ sudo bash” the following error appears: row 5: cd: / root / svn / R-devel-build: file or directory not found row 7: ../r-devel/R/configure: file or directory not found
    make: ***No target indicated and no make file found. Stop.

    When I run without “sudo”, the procedure stops at the part that needs to create the directory inside usr/local/lib/R-devel.

    Any suggestion?

    I use Debian!

Leave a Reply (Markdown is enabled)

This site uses Akismet to reduce spam. Learn how your comment data is processed.