From csardi.gabor at gmail.com  Fri Dec 16 22:27:28 2016
From: csardi.gabor at gmail.com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Fri, 16 Dec 2016 21:27:28 +0000
Subject: [Rd] Upgrading a package to which other packages are LinkingTo
In-Reply-To: <4bc01854-5884-3566-d300-1675ecca518c@gmail.com>
References: <e04b65b6-bb5e-b0ae-9c30-761c20ad24a4@ivt.baug.ethz.ch>
	<341cb7cf-03f6-d70d-464f-a87c77617c9b@gmail.com>
	<22611.60978.786479.630863@max.nulle.part>
	<8555d7b8-e2da-38f7-f133-9e7d46cf74b6@gmail.com>
	<22612.2793.857104.239264@max.nulle.part>
	<52a8bf02-b3d0-51a4-3bb3-162758156623@gmail.com>
	<22612.5114.200686.241246@max.nulle.part>
	<CABz6aZfAHMVLNo2hnYk8j8mjLyqq2LXvAUmqLVnj7cE7E8dQtw@mail.gmail.com>
	<4bc01854-5884-3566-d300-1675ecca518c@gmail.com>
Message-ID: <CABtg=Kno5kv+YcisXc+UmEQv0xS33re3MGOZXYus=U=qeGz9Dw@mail.gmail.com>

I think that this problem is actually more general than just ABI
versioning. The common definition of ABI refers to compiled code, but
with R packages similar problems might happen (and they to happen)
without any compiled code.

I think the key issue is the concept of build-time dependencies. While
R packages usually does not distinguish between build-time and
run-time dependencies, they still do exist, and I think ideally we
would need to treat them differently.

AFAIK LinkingTo is the only form of a build-time dependency, that is
completely explicit, so it is relatively easy to handle. The other
frequent of build-time dependency is a function call to the other
package, that happens at install time. E.g. with references or R6*
classes you frequently include code like this in yourpackage:

myclass <- R6::R6Class(...)

and this code is evaluated at install time. So if the R6 package is
updated, the installed version myclass in yourpackage is not affected
at all. In fact, if the new version of R6 is not compatible with the
myclass object created by the old version, then yourpackage will be
broken. (This AFAIK cannot happen with R6, so it is not the best
example, but it can happen in other similar cases.)

The key here is that R6 is a build-time dependency of yourpackage,
similarly to packages linking to (i.e. LinkingTo) Rpp.

Another possible type of build-time dependency is if you put objects
from another package in yourpackage. E.g.

myfun <- otherpkg::fun

Then a copy of otherpkg::fun will be saved in yourpackage. If you
install a new version of otherpkg, yourpackage is unaffected, and if
otherpkg::fun uses some (possibly internal) API from otherpkg, that
has changed in the new version of otherpkg, you might easily end up
with a broken yourpackage again.

I think one lesson is to avoid running code at install time. This is
not a new thing, AFAIR it is even mentioned in 'Writing R extensions'.
Instead of running code at install time, you might consider running it
in `.onLoad()`, and then these "problems" go away. But you obviously
cannot always avoid it.

Gabor

* I think the R6 package is great, and I am not speaking in any way
against it. I just needed an example, and I know R6 much better than
reference classes, or other similar packages.



[Rd] Upgrading a package to which other packages are LinkingTo
=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=