diff --git a/CRAN_Release.cmd b/CRAN_Release.cmd index ada6baf4c6..a254b41779 100644 --- a/CRAN_Release.cmd +++ b/CRAN_Release.cmd @@ -582,7 +582,10 @@ ls -1 *.tar.gz | grep -E 'Chicago|dada2|flowWorkspace|LymphoSeq' | TZ='UTC' para # Release to CRAN ############################################### -Bump versions in DESCRIPTION and NEWS (without 'on CRAN date' text as that's not yet known) to even release number +Bump version to even release number in 3 places : + 1) DESCRIPTION + 2) NEWS (without 'on CRAN date' text as that's not yet known) + 3) dllVersion() at the end of init.c DO NOT push to GitHub. Prevents even a slim possibility of user getting premature version. Even release numbers must have been obtained from CRAN and only CRAN. (Too many support problems in past before this procedure brought in.) R CMD build . R CMD check --as-cran data.table_1.11.8.tar.gz @@ -597,6 +600,7 @@ Thanks and best, Matt 1. Bump version in DESCRIPTION to next odd number 2. Add new heading in NEWS for the next dev version. Add "(date)" on the released heading if already accepted. 3. Bump 3 version numbers in Makefile +4. Bump dllVersion() in init.c Push to GitHub so dev can continue. Commit message format "1.11.8 submitted to CRAN. Bump to 1.11.9" Bump dev number text in homepage banner Cross fingers accepted first time. If not, push changes to devel and backport locally diff --git a/NEWS.md b/NEWS.md index 2d7a03d5b1..2e2959f7fb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -74,7 +74,7 @@ #### NOTES -1. When data.table first loads it now checks the DLL's MD5. This is to detect installation issues on Windows when you upgrade and i) the DLL is in use by another R session and ii) the CRAN source version > CRAN binary binary which happens just after a new release (R prompts users to install from source until the CRAN binary is available). This situation can lead to a state where the package's new R code calls old C code in the old DLL; [R#17478](https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478), [#3056](https://github.com/Rdatatable/data.table/issues/3056). This broken state can persist until, hopefully, you experience a strange error caused by the mismatch. Otherwise, wrong results may occur silently. This situation applies to any R package with compiled code not just data.table, is Windows-only, and is long-standing. It has only recently been understood as it typically only occurs during the few days after each new release until binaries are available on CRAN. Thanks to Gabor Csardi for the suggestion to use `tools::checkMD5sums()`. +1. When data.table loads it now checks its DLL version against the version of its R level code. This is to detect installation issues on Windows when i) the DLL is in use by another R session and ii) the CRAN source version > CRAN binary binary which happens just after a new release (R prompts users to install from source until the CRAN binary is available). This situation can lead to a state where the package's new R code calls old C code in the old DLL; [R#17478](https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478), [#3056](https://github.com/Rdatatable/data.table/issues/3056). This broken state can persist until, hopefully, you experience a strange error caused by the mismatch. Otherwise, wrong results may occur silently. This situation applies to any R package with compiled code not just data.table, is Windows-only, and is long-standing. It has only recently been understood as it typically only occurs during the few days after each new release until binaries are available on CRAN. 2. When `on=` is provided but not `i=`, a helpful error is now produced rather than silently ignoring `on=`. Thanks to Dirk Eddelbuettel for the idea. diff --git a/R/onLoad.R b/R/onLoad.R index e8eab15247..98b6e1799b 100644 --- a/R/onLoad.R +++ b/R/onLoad.R @@ -2,11 +2,16 @@ .onLoad <- function(libname, pkgname) { # Runs when loaded but not attached to search() path; e.g., when a package just Imports (not Depends on) data.table + if (!exists("test.data.table", .GlobalEnv, inherits=FALSE) && # check when installed package is loaded but skip when developing the package with cc() + (dllV<-.Call(CdllVersion)) != (RV<-packageVersion("data.table"))) { + dll = if (.Platform$OS.type=="windows") "dll" else "so" + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478 + stop("The datatable.",dll," version (",dllV,") does not match the data.table package's version (",RV,"). Please close all R sessions to release the ",toupper(dll)," and reinstall data.table in a fresh R session. The general issue that R's package installer can leave a package in a state that is apparently functional but with new R code calling old C code silently has been filed here: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478. Please comment there if this happens to you. This misatch between R and C code can happen with any package, not just data.table. It is just that data.table has added this check.") + } if (identical(tools::checkMD5sums("data.table"), FALSE)) { # checkMD5sums outputs messages using cat() and returns NA when MD5 file is not available. The MD5 file is included in the # binary builds that CRAN produces. - stop("This data.table installation appears to be faulty. Please close all R sessions and reinstall data.table.") - # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478 + stop("This data.table installation appears to be faulty; tools::checkMD5sums returned FALSE. Please close all R sessions and reinstall data.table.") } "Please read FAQ 2.23 (vignette('datatable-faq')) which explains in detail why data.table adds one for loop to the start of base::cbind.data.frame and base::rbind.data.frame. If there is a better solution we will gladly change it." diff --git a/src/init.c b/src/init.c index b117ea756f..4bedc94da0 100644 --- a/src/init.c +++ b/src/init.c @@ -79,6 +79,7 @@ SEXP between(); SEXP hasOpenMP(); SEXP uniqueNlogical(); SEXP frollfunR(); +SEXP dllVersion(); // .Externals SEXP fastmean(); @@ -160,6 +161,7 @@ R_CallMethodDef callMethods[] = { {"ChasOpenMP", (DL_FUNC) &hasOpenMP, -1}, {"CuniqueNlogical", (DL_FUNC) &uniqueNlogical, -1}, {"CfrollfunR", (DL_FUNC) &frollfunR, -1}, +{"CdllVersion", (DL_FUNC) &dllVersion, -1}, {NULL, NULL, 0} }; @@ -322,3 +324,8 @@ SEXP hasOpenMP() { #endif } +SEXP dllVersion() { + // .onLoad calls this and checks the same as packageVersion() to ensure no R/C version mismatch, #3056 + return(ScalarString(mkChar("1.11.9"))); +} +