Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check_linked_version() #926

Merged
merged 3 commits into from
Feb 26, 2020
Merged

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented Feb 24, 2020

Implements check_linked_version() in a standalone file that can be copied in zero-dep packages. After some testing in other packages it will be exported from rlang as well.

Packages that include native code are fragile on Windows and might not be properly updated. When the package is loaded in memory, R might install a new version of the package without updating the corresponding DLL because. With check_linked_version() you can preventively inform your users about broken installation.

It should be called from the .onLoad() hook:

.onLoad <- function(lib, pkg) {
  check_linked_version(pkg, with_rlang = FALSE)
}

It expects that the namespace of the checked package contains a C callable called *pkgname*_linked_version(). This callable should return the package version as a string. The version recorded in the native library is then compared to the one returned from packageVersion(). If they don't match, an informative error is thrown:

Error: The vctrs package is not properly installed.The DLL version (0.10.99.9005) does not correspond to the package version (0.2.99.9005).Please update vctrs with `install.packages("vctrs")` and restart R.

On Windows the error message includes additional advice from rstats-wtf/what-they-forgot#62 about safely reinstalling packages:

Error: The vctrs package is not properly installed.The DLL version (0.10.99.9005) does not correspond to the package version (0.2.99.9005).Please update vctrs to the latest version.Updating packages on Windows requires precautions:
  <https://github.com/jennybc/what-they-forgot/issues/62>

A usethis tool will eventually make it easy to generate an up-to-date version.c file at each version bump.

@lionel- lionel- requested a review from hadley February 25, 2020 09:44
@lionel- lionel- merged commit fff1388 into r-lib:master Feb 26, 2020
@lionel- lionel- deleted the add-check-linked-version branch February 26, 2020 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants