Take control of your R code. RStudio is an integrated development environment (IDE) for R. It includes a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management. R version 4.0.2 (Taking Off Again) has been released on 2020-06-22. R version 3.6.3 (Holding the Windsock) has been released on 2020-02-29. You can support the R Foundation with a renewable subscription as a supporting member; News via Twitter News from the R Foundation.
When you upgrade to a new version of R on your computer, it’s possible that everything will continue to work without any trouble, but it’s also possible that you’ll run into problems. In some cases, the new version of R won’t find your existing R packages. In other cases, R will find the existing packages, but they might not work correctly. The article of this document is to explain these problems, and how to fix them.
On most single-user systems (Mac, Windows, and Linux), when you upgrade to a new minor version of R (like 3.3.0 to 3.4.0), R will not find the packages, you will need to reinstall your R packages. This is an inconvenience, but the problem is obvious and it is easy to fix. If you are using a system like this, you can just reinstall your packages after upgrading R. You probably don’t need to read the rest of this document unless you want to learn much more about package libraries.
On servers running Linux, it is possible that after an R version upgrade, your R packages will load without trouble, but they might not work correctly, or they might even crash R when used. Because the cause of these problems will not be obvious, upgrading R on a server should be done with care.
In a production environment, we strongly suggest testing new versions of R and packages on a staging server before deploying to a production server.
R version numbers have the form major.minor.subminor
. The current version as of the writing of this document, 3.4.0, has a major version 3, minor version 4, and subminor version 0. New minor versions are released about once per year. In general, there are no issues with subminor version upgrades, like going from 3.3.2 to 3.3.3, but there can be compatibility problems when there is a major or minor version upgrade.
User libraries and version incompatibilities
There are two possible sources of problems with R version upgrades, both of which are related to package libraries. (A library is a directory where packages are stored.)
One problem is that, after upgrading to a new version of R, packages are no longer found because there is a new library. When this happens, the problem is obvious: when R code calls library()
, it throws an error and reports that the package is missing.
The other problem that happens is more subtle. Sometimes packages installed with a previous version of R will not work correctly with the new version of R. Sometimes they can crash the R process. And even when there is a crash, it will not be obvious that this it is because the package was installed with an old version of R.
In both cases, the solution is to reinstall packages with the new version of R.
Detecting which version of R a package was built with
The following code will show which packages are installed, their version numbers, and which version of R they were built with. The user is running R 3.4.0 and most of the installed packages were built with R 3.4.0, but others were built with R 3.2.0.
In this particular case, the Cairo package was able to be loaded with library(Cairo)
, but when functions from the package were called, it caused a segfault, crashing the R process. This is because it was built with an older version of R.
This issue most frequently happens on Linux, when root has installed some packages, though it can happen in other cases as well, if a customized configuration is used.
Reinstalling packages with the new version of R
After upgrading R, if you have any packages that were built with an older version of R, you should reinstall those packages to avoid compatibility issues. There are two methods described below: one upgrades all packages to the latest available version of that package, and the other reinstalls packages with the currently-installed version. For example, if you have Shiny version 1.0.1 installed, and the latest available version is 1.0.3, the first method will install Shiny 1.0.3, while the second method will reinstall 1.0.1 (built with the current version of R).
The following code should be run as root after upgrading R on Linux. It can also be run as a regular user, but in that case it will store the packages in the user’s personal library, and won’t help other users. If this code is run as root after an R version upgrade, then users should not need to run this code (unless they have their own copies of the same packages in their personal library).
The first way is to use the base R function update.packages()
, with checkBuilt=TRUE
. Normally, the update.package()
function will only reinstall packages for which a newer version available, but the checkBuilt=TRUE
option tells it to also reinstall packages if they were built with an older version of R, even if the version of the package will remain the same.
In many cases, it is useful to update all packages to the latest available version, but it’s possible that some changes in the packages could cause your code to behave differently.
The pkgsnap package provides a way to reinstall packages without changing their version. pkgsnap is not yet on CRAN, but you can currently install it from GitHub.
Technical details
The information above should be enough to help diagnose and solve the problem, but if you’d like a more comprehensive understanding of the problem, read on. Each platform (Mac, Windows, and various flavors of Linux) has a different default configuration, and therefore has different default behavior. This document will also explain the default settings for each platform, and what that means for dealing with R upgrade issues.
User and site libraries
In all R installations, there is a site library: packages installed there are available to all users. (In some installations, there is more than one site library.) Some R installations are also configured to have a user library: packages installed in a user library are available only to that user.
When a regular user starts R, it will recognize both the user library (if configured for it) and the site library. If present, the user library is where packages will be installed to. If there is no user library, then packages will be installed to the site library, assuming the user has the correct permissions to do so.
When a system’s superuser (root) starts R, it uses only the site library (or libraries), and that is where packages will be installed to. This is not how packages are usually installed, but it is sometimes done this way on servers.
To find the libraries for your user, you can run .libPaths()
from the R prompt. For example, this is what shows on Ubuntu Linux:
Users can configure their library path by setting the R_LIBS_USER
variable in a file called .Renviron
in their home directory. At a system level, the library path(s) can be set with an Renviron.site
file. See the R startup documentation page for more information.
Versioned and unversioned libraries
In some installations (typically on Linux), R is configured to keep the same site library across R version upgrades. The problem here is that packages that built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. (Note that Subminor version upgrades of R generally do not introduce incompatibilities.)
In other installations (typically on Mac and Windows), R is configured to use a new library when R has a major or minor version upgrade. The advantage of this is that you won’t experience package incompatibilities. The drawback is that you must reinstall your packages after upgrading R.
Customized library paths
The user and site library paths can be customized. At the user level, this is done with a file named ~/.Renviron
, and at the system level, this is usually done with a file named /etc/R/Renviron.site
. See the R startup documentation for more information.
Platform-specific notes
The default library configuration differs across platforms, and so the behavior after an R version upgrade also differs across platforms.
Windows
On Windows, the default user library has the major.minor version in the path. The default site library has the major.minor.subminor version.
With this configuration, user-installed packages get installed in the user library. (The site library will just contain “base” R packages that are installed along with R itself.) Only R version upgrades that involve a minor version change will result in the user library changing. When this happens, you will need to reinstall all your packages.
On Windows, upgrading R is something that is usually done by the user of the machine, so it shouldn’t be much of a surprise when R cannot find old installed packages.
Summary:
- Upgrade is usually done explicitly by user.
- User library is versioned to minor.
- Site library is versioned to subminor.
- Unlike on Mac and Linux, when R is run as an administrator on Windows, it will still install packages to the user’s personal library by default, but it can also install to the site library if specified.
macOS
On macOS, the default configuration does not have a user library. The site library has the major.minor version in the path.
With this configuration, user-installed packages get installed into the site library. (Users on macOS usually have permission to write to the site library.) R version upgrades that involve a minor version change will require the user to reinstall all packages.
On a Mac, upgrading R is usually done by the user of the machine, so it shouldn’t be a surprise when the new version of R cannot find old installed packages.
Summary:
- Upgrade is usually done explicitly by user.
- Does not have user library, so packages install to site library.
- Site library is versioned to subminor.
Linux
On Linux, the default user library has the major.minor version in the path. The site library is not versioned. There can be multiple site libraries, though this should not cause any differences in most use cases.
Debian / Ubuntu:
Red Hat / Centos:
SUSE / openSUSE:
The process of upgrading R on Linux is different from upgrading it Mac and Windows. On Mac and Windows, the user usually needs to go download the new version of R and install it, so it is obvious when R is upgraded. On Linux, R is usually upgraded in the process of a system software update, such as when you run apt-get upgrade
on Debian or Ubuntu. Additionally, Linux systems often have different people administering them and using them. For these two reasons, the installed version of R can change without the user being aware of it.
User-installed packages go into the user library. The site library by default will contain only “base” packages included with R itself. After R gets a minor version upgrade, the user will find that their user-installed packages are no longer available, and will need to reinstall all of them. This may come as a surprise to users, but the solution is straightforward.
When Linux is being used on a server, there is another, more difficult scenario: the system administrator may install some packages as root, so that they’re available for all users. When R is upgraded, those packages will continue to be available even after a major or minor version upgrade, but they potentially could be incompatible with the new version of R. If this happens, users will experience problems like the ones described previously.
In these cases, a user or system administrator should check which version of R each package was built with, and reinstall those packages that were built with an old version of R, as described above. One risk of doing this is that this will not only reinstall those R packages, but also upgrade the versions of those packages, which could cause problems if the newer version of the package has different behavior.
Because of these potential problems, administrators of Linux servers should be exercise caution when upgrading R. On most Linux distributions, it is possible to freeze system packages (like R) to a specific version, and only upgrade after testing.
Summary:
- Upgrade is usually something that happens with
apt-get upgrade
oryum update
, and user might not be aware when it occurs. - User library is versioned to minor.
- Site library is not versioned.
All software on this page is strictly experimental and subject to acceptance of the supplied R license agreement and the disclaimer at the end of the page.
Starting with R 4.0.0 alpha we are building R using standard Apple tools (Xcode 11.4) and GNU Fortran 8.2 from fxcoudert and the target is macOS 10.13 (High Sierra). All dependent static libraries are available in the libs-4 directory. Please make sure you remove any modifications to build flags from your home since no custom compilers are used anymore. For more information about alternative OpenMP options (as in older version) see the openmp page of this site.
Index
Nightly builds for macOS
R framework
Build | OS | Date | Status | Download |
---|---|---|---|---|
R-3.6-branch 3.6.3 Patched (2020/04/28, r78971) | el-capitan | Aug 4 23:30 | x86_64: OK (log) Package: OK | R-3.6-branch-el-capitan-sa-x86_64.tar.gz (67Mb) R-3.6-branch-el-capitan-signed.pkg (77Mb, installer incl. GUI) |
R-4.0-branch 4.0.3 RC (2020/10/08, r79317) | high-sierra | Oct 9 21:41 | x86_64: OK (log) Package: OK | R-4.0-branch.tar.gz (73Mb) R-4.0-branch.pkg (85Mb, installer incl. GUI) |
R-devel 4.1.0 Under development (unstable) (2020/10/09, r79317) | high-sierra | Oct 9 21:52 | x86_64: OK (log) Package: OK | R-devel.tar.gz (73Mb) R-devel.pkg (85Mb, installer incl. GUI) |
The installer image (*.pkg) is packaged exactly the same way as the CRAN release of R (including the GUI) and it will update your R version (unless you use pkgutil - see instructions during installation and/or the 'Multiple versions'section of the R Installation and Administration manual).
Alternatively, you can use the tar-ball (*.tar.gz) in the table above. The tar-ball must be unpacked in the root directory using:
$ tar fvxz R*.tar.gz -C /
NOTE: The tar-ball does not contain the GUI (see below for a separate download).
NOTE: The installer includes Tcl/Tk package which will install in /usr/local. It is optional (only needed for the tcltk R package) and can be unchecked at installation time.
If you see any issues with the builds, please contact Simon Urbanek (the macOS maintainer of R) or report on the R-SIG-Mac mailing list.
Mac OS X GUI
Version | Build | Download |
---|---|---|
Mac OS X GUI rev. 7782 for R 3.6.x | el-capitan-Debug.dmg | R-GUI-7782-3.6-el-capitan-Debug.dmg |
Mac OS X GUI rev. 7782 for R 3.6.x | el-capitan-Release.dmg | R-GUI-7782-3.6-el-capitan-Release.dmg |
Mac OS X GUI rev. 7891 for R 4.0.x | high-sierra-Debug.dmg | R-GUI-7891-4.0-high-sierra-Debug.dmg |
Mac OS X GUI rev. 7891 for R 4.0.x | high-sierra-Release.dmg | R-GUI-7891-4.0-high-sierra-Release.dmg |
Mac OS X GUI rev. 7891 for R 4.1.x | high-sierra-Debug.dmg | R-GUI-7891-4.1-high-sierra-Debug.dmg |
Mac OS X GUI rev. 7891 for R 4.1.x | high-sierra-Release.dmg | R-GUI-7891-4.1-high-sierra-Release.dmg |
To install, open the image and drag the R icon to your Applications folder. Alternatively the GUI can be run directly off that image without copying if you just want to test it. Build configurations with '64' suffix are 64-bit builds, all others are 32-bit (except for Debug). If you want to use both, rename one of them or place them in different directories.
R Version 3.4 Mac Download Windows 10
Tools
In order to compile R and R packages you will need Xcode Developer Tools and a Fortran compiler. For details and download, please read the Tools page. The R 4.0.0 and higer binaries are built using Xcode 11.4.Experimental binary packages
This site no longer hosts experimental packages. It is now the master repository for released R package binaries. If you have issues with other mirrors, try using https://mac.r-project.org/ as your mirror as it is updated first.Legacy R
The current build supports only macOS X 10.13 (High Sierra) or higher. Older versions of macOS are not supported in binary form, but R can be compiled from sources for such legacy OS versions. Last released version for Mac OS X 10.4 (Tiger) was R 2.10.1, last release for Mac OS X 10.5 (Leopard) was R 2.15.3, last release for Mac OS X 10.11 (El Capitan) wasDownload Mac Version 10.14
R 3.6.3Download New Version Of Mac
.Other binaries
Latest Mac Version
The following binaries are not maintained or supported by R-core and are provided without any guarantee and for convenience only (Mac OS X 10.4.4 or higher required). They match the binaries used on the CRAN binary build machine and thus are recommended for use with CRAN R package binaries.- GTK+ 2.24.17 framework - 64-bit build of GTK+ 2.24.17, necessary for binary R packages that use GTK+ version 2 (such as RGtk2+). R 3.0.0 and higher, Snow Leopard build
Download: GTK_2.24.17-X11.pkg (ca. 41MB) - GTK+ 2.18.5 framework - universal build of GTK+ 2.18.5, necessary for binary R packages that use GTK+ version 2 (such as RGtk2+). R 2.10.0 - 2.15.3, Leopard build
Download: GTK_2.18.5-X11.pkg (ca. 58MB) - RSwitch - a small GUI that allows you to switch between R versions quickly (if you have multiple versions of R framework installed).
Download: RSwitch-1.2.dmg (ca 67kB, universal, updated 2011/03/24 to support R 2.13.0 and up)
Sources: RSwitch-1.2.tar.gz (Xcode project and sources)NOTE: Bob Rudis is maintaining a new version of a tool which has RSwitch functionality and more - see 3rd party RSwitch replacement (NOT related to R-Foundation or CRAN!).
R Version 3.4 Mac Download Free
More external libraries for R 4.0.0 and higher can be found in the /libs-4/ directory. For older versions see the /libs/ directory.
Comments are closed.