diff --git a/NEWS.md b/NEWS.md index f973a9c12c..84d6e683ef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -203,6 +203,8 @@ 59. 55. Added `+.IDate` method so that IDate + integer doesn't revert to `Date`, [#1528](https://github.com/Rdatatable/data.table/issues/1528); thanks @MichaelChirico for FR&PR. + 60. Fixed test in `onAttach()` for when `Packaged` field is missing from `DESCRIPTION`, [#1706](https://github.com/Rdatatable/data.table/issues/1706); thanks @restonslacker for BR&PR. + #### NOTES 1. Updated error message on invalid joins to reflect the new `on=` syntax, [#1368](https://github.com/Rdatatable/data.table/issues/1368). Thanks @MichaelChirico. diff --git a/R/onAttach.R b/R/onAttach.R index fd15a48d8c..dd2ff732d1 100644 --- a/R/onAttach.R +++ b/R/onAttach.R @@ -1,13 +1,22 @@ .onAttach <- function(libname, pkgname) { - # Runs when attached to search() path such as by library() or require() - if (interactive()) { - v = packageVersion("data.table") - d = read.dcf(system.file("DESCRIPTION", package="data.table"))[,"Packaged"] - dev = as.integer(v[1,3])%%2 == 1 # version number odd - packageStartupMessage("data.table ", v, if(dev) paste0(" IN DEVELOPMENT built ", d)) - if (dev && (Sys.Date() - as.Date(d))>28) packageStartupMessage("**********\nThis development version of data.table was built more than 4 weeks ago. Please update.\n**********") - packageStartupMessage('For help type ?data.table or https://github.com/Rdatatable/data.table/wiki') - packageStartupMessage('The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way') + # Runs when attached to search() path such as by library() or require() + if (interactive()) { + v = packageVersion("data.table") + d = read.dcf(system.file("DESCRIPTION", package="data.table"), fields = c("Packaged", "Built")) + if(is.na(d[1])){ + if(is.na(d[2])){ + return() #neither field exists + } else{ + d = unlist(strsplit(d[2], split="; "))[3] + } + } else { + d = d[1] } + + dev = as.integer(v[1,3])%%2 == 1 # version number odd + packageStartupMessage("data.table ", v, if(dev) paste0(" IN DEVELOPMENT built ", d)) + if (dev && (Sys.Date() - as.Date(d))>28) packageStartupMessage("**********\nThis development version of data.table was built more than 4 weeks ago. Please update.\n**********") + packageStartupMessage('For help type ?data.table or https://github.com/Rdatatable/data.table/wiki') + packageStartupMessage('The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way') + } } -