3  Installing R under Windows

[The rest of this paragraph is only relevant after release.] The bin/windows directory of a CRAN site contains binaries for a base distribution and a large number of add-on packages from CRAN to run on 64-bit x86_64 Windows.

R is most tested on current versions of Windows 10 and Windows Server 2022 with UTF-8 as the charset encoding. It works also on Windows 11. It runs on older versions of Windows, but normally with other charset encoding and may require manual installation of the Universal C Runtime (UCRT).

Your file system must allow long file names (as is likely except perhaps for some network-mounted systems). If it does not also support conversion to short name equivalents (a.k.a. DOS 8.3 names), then R must be installed in a path that does not contain spaces.

Installation is via the installer R-4.3.3-win.exe. Just double-click on the icon and follow the instructions. You can uninstall R from the Control Panel.

You will be asked to choose a language for installation: that choice applies to both installation and un-installation but not to running R itself.

See the R Windows FAQ for more details on the binary installer and for information on use on older Windows systems.

3.1 Building from source

It is possible to use other 64-bit toolchains (including ‘MSYS2’) with UCRT support to build R, but this manual only documents that used for recent binary distributions of R. When using other toolchains, makefiles of R and packages may need to be adapted.

3.1.1 The Windows toolset

The binary distribution of R is currently built with tools from Rtools44 for Windows. See Building R and packages for more details on how to use it.

The toolset includes compilers (currently GCC version 13.2.0 with selected additional patches) and runtime libraries from the ‘MinGW-w64’ project and a number of pre-compiled static libraries and headers used by R and R packages, compiled by ‘MXE’ (M cross environment, with updates maintained by Tomas Kalibera). The toolset also includes build tools from the the ‘MSYS2’ project. Additional build tools packaged by ‘MSYS2’ may be installed via a package manager (pacman).

There is also an experimental variant of Rtools44 with support for 64-bit ARM CPUs (aarch64) via LLVM 17 toolchain using clang/flang-new compilers, lld linker, and libc++.

The toolsets used for 64-bit Windows from 2008 to 2022 were based on MinGW-w64. The assistance of Yu Gong at a crucial step in porting R to MinGW-w64 is gratefully acknowledged, as well as help from Kai Tietz, the lead developer of the MinGW-w64 project and from Martin Storsjo.

3.1.2 LaTeX

Both building R and checking packages need a distribution of LaTeX installed, with the directory containing pdflatex on the path.

The MiKTeX (https://miktex.org/) distribution of LaTeX is that used on CRAN. This can be set up to install extra packages ‘on the fly’ (without asking), which is the simplest way to use it. The ‘basic’ version of MiKTeX will need to add some packages.1 In any case ensure that the inconsolata package is installed—you can check with the MiKTeX Package Manager.

1 There are reports of segfaults when MiKTeX installs additional packages when making NEWS.pdf: re-running make seems to solve this.

It is also possible to use the TeX Live distribution from https://www.tug.org/texlive/. (The CRAN package tinytex can install and manage a subset of TeX Live.)

3.2 Checking the build

You can test a build by running

make check

The recommended packages can be checked by

make check-recommended

Other levels of checking are

make check-devel

for a more thorough check of the R functionality, and

make check-all

for both check-devel and check-recommended.

If a test fails, there will almost always be a .Rout.fail file in the directory being checked (often tests/Examples or tests): examine the file to help pinpoint the problem.

Parallel checking of package sources (part of make check-devel and make check-recommended) is possible: see the environment variable TEST_MC_CORES to the maximum number of processes to be run in parallel.

3.3 Testing an Installation

The Windows installer contains a set of test files used when building R.

The toolset is not needed to run these tests, but more comprehensive analysis of errors will be given if diff is in the path.

Launch either Rgui or Rterm (preferred), preferably with --vanilla. Then run

Sys.setenv(LC_COLLATE = "C", LC_TIME="C", LANGUAGE = "en")
tools::testInstalledBasic("both")
tools::testInstalledPackages(scope = "base")
tools::testInstalledPackages(scope = "recommended")

runs the basic tests and then all the tests on the standard and recommended packages. These tests can be run from anywhere: testInstalledBasic writes results in the tests folder of the R home directory (as given by R.home()) and testInstalledPackages under the current directory unless a different one is specified by outDir.

For the tests folder to be writeable, one normally needs to install R to a directory other than the default C:\Program Files. The installer also allows to install R without Administrator privileges, see the R Windows FAQ for more details.

The results of example(md5sums) when testing tools may differ from the reference output as some files are installed with Windows’ CRLF line endings. Also, expect differences in reg-plot-latin1.pdf.

One can also run tests from the toolset shell (e.g. bash) similarly to a Unix-like installation. Move to the home directory of the R installation (as given by R RHOME or from R as R.home()) and run

cd tests
## followed by one of
../bin/R CMD make check
../bin/R CMD make check-devel
../bin/R CMD make check-all

Remember that LaTeX needs to be on the path.

Footnotes