Michal Charemza
Michal Charemza

Reputation: 27062

Are binary R packages compatible across different versions of R on Linux?

For a compiled R package on Linux, should the compiled package install and work fine on versions of R later than the version used to compile it?

The context is that I’m making a (private) repository of compiled packages, and wondering if there should be separation by R version. (Will also have separation by major version of distribution, in this case Debian)

Upvotes: 1

Views: 80

Answers (1)

Ada Lovelace
Ada Lovelace

Reputation: 1285

Yes, it generally does as the 'ABI' (application binary interface) tends to be stable across R releases.

But if it changes, and recompilation is required / imposed this is clearly signalled. For example on my machine I have a (leaving it unnamed for now, local) package built ages ago. Loading it yields

> library(abcDEF)
Error: package or namespace load failed for ‘abcDEF’:
 package ‘abcDEF’ was installed before R 4.0.0: please re-install it
> 

On the other hand, I just loaded another package that was compiled / installed locally in 2020 without a problem. Its DESCRIPTION file of the installed package says

Built: R 4.0.0; x86_64-pc-linux-gnu; 2020-04-26 22:49:08.53212 UTC; unix

and I am now running R 4.4.1.

PS: Calling installed.packages() tells you in column 'Built' which R version was used to install it. In a Docker container I see

> IP <- installed.packages()
> table(IP[,"Built"])

4.2.0 4.3.0 4.3.2 4.4.0 4.4.1 
    4     8     1     6    14 
> 

further demonstrating that while can force yourself to reinstall on major.minor changes it really is not required (outside the aforementioned, and rare, documented ABI breaks).

Upvotes: 2

Related Questions