R
devel from source on 64-Bit Ubuntu & checking a packageBefore uploading a package to CRAN, it has to be tested using a recent development version of R
that has to be installed from source:
Please ensure that R CMD check –as-cran has been run on the tarball to be uploaded before submission. This should be done with the current version of R-devel (or if that is not possible and explained in the submission, current R-patched or the current release of R.) – CRAN Repository Policy
Note: Henrik Singmann has a (probably better) tutorial for installing R devel from source, but the last update is from 2019.
Appendix A1 “Essential programs and libraries” in “R Installation and Administration” contains requisite packages for installation from source. Interestingly, Java is necessary to build R from source:
sudo apt install openjdk-11-jdk
Some dependencies are needed to build the documentation in pdf format using Latex. The following packages are for example needed:
texi2dvi
, available viasudo apt install texinfo
qpdf
, available via
sudo apt install qpdf
Cairo is also needed for images in vignettes, via
sudo apt install libcairo2-dev
R
from sourcetar -xf R-devel.tar.gz
cd R-devel
./tools/rsync-recommended
./configure
However, just using ./configure
may not work:
Unless you do not want to view graphs on-screen (or use macOS) you need ‘X11’ installed, including its headers and client libraries. For recent Fedora/RedHat distributions it means (at least) RPMs ‘libX11’, ‘libX11-devel’, ‘libXt’ and ‘libXt-devel’. On Debian/Ubuntu we recommend the meta-package ‘xorg-dev’. If you really do not want these you will need to explicitly configure R without X11, using –with-x=no. – Appendix A1 in “R Installation and Administration”
Then, we need:
./configure --with-x=no
Or:
./configure --with-readline=no --with-x=no --with-cairo
Note: As of 2023/2024 it was always sufficient for me to just use ./configure
.
make
make check
Tests if the installation was successful.
R
can now be started using the script R
in directory bin
:cd bin
./R
R
devel on the system by usingmake install
but I guess this is not recommended because this replaces the current stable installation of R
. However, it is also possible to have multiple R
versions at the same time.
To test your package using R CMD check
, you need to make the dependencies of your packages available to R
devel. That is, install all of the packages in Imports
, Depends
, and Suggests
.
Installing packages is actually accomplished by just using install.packages()
. Packages will be installed into the directory in the R
variable .Library
, which was R-devel/library
in my case. Thus, these packages do not mess with your normal package libraries.
R
develcd bin
./R CMD build "path/to/package"
Be sure to replace path/to/package
by the actual path to the package on your system.
./R CMD check --as-cran tar-ball.tar.gz
I usually ignore the warning “‘qpdf’ is needed for checks on size reduction of PDFs” and the note “Skipping checking HTML validation: no command ‘tidy’ found”, which are not relevant for CRAN.
Note: Save yourself some pain and just use the win builder. If you choose not to, the notes below may or may not help.
Some extra work may be required to check your package on a Windows system. Fortunately, at least, we can use R CMD build
and R CMD check
in the RStudio terminal. I had to get latex running so that R CMD check
can build the pdf manuals. First, we have to install Miktex. After installing Miktex, a restart is required so R
finds the path to Latex.
Before R CMD check
worked properly, however, I had to enable some fonts as described here. Put the following in the standard Windows terminal:
initexmf --update-fndb
initexmf --edit-config-file updmap
The second command opens the text editor where we put:
Map zi4.map
Last, we type
initexmf --mkmaps
into the terminal. Then, R CMD check
should work on the tar ball that can be build using the RStudio terminal via R CMD build "."
(in the procect directory of the package).
I did not try to install R devel from source though on Windows, but used the released version. This seemed to be enough.
Last updated: 2024-04-24