diff --git a/DESCRIPTION b/DESCRIPTION index 9b0121f6..fcb126d1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: mlr3misc Title: Helper Functions for 'mlr3' -Version: 0.12.0-9000 +Version: 0.13.0-9000 Authors@R: c( person("Michel", "Lang", , "michellang@gmail.com", role = c("cre", "aut"), comment = c(ORCID = "0000-0001-9754-0393")), diff --git a/NEWS.md b/NEWS.md index 26465595..0f9de943 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ -# mlr3misc 0.13.0 +# mlr3misc 0.13.0-9000 -* Bugfix: disable leanification when `ROXYGEN_PKG` environment variable is set +* Feat: Loading `mlr3misc` now gives a warning when the package is being installed + with source references, which can lead to unreasonable memory usage. + This can be disabled using option `"mlr3misc.warn_srcref"` +* Fix: disable leanification when `ROXYGEN_PKG` environment variable is set # mlr3misc 0.13.0 diff --git a/R/leanify.R b/R/leanify.R index 4dc21974..376c4e79 100644 --- a/R/leanify.R +++ b/R/leanify.R @@ -120,3 +120,8 @@ leanify_package = function(pkg_env = parent.frame(), skip_if = function(x) FALSE } } } + +has_srcref = function(fn) { + # we could also just inspect the attributes but this would evaluate the promise + !identical(as.character(substitute(lines, attr(attr(fn, "srcref"), "srcfile")$original)), "lines") +} diff --git a/R/zzz.R b/R/zzz.R index 5ed2d8fe..367371a5 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -5,9 +5,19 @@ #' @importFrom R6 R6Class is.R6 #' @importFrom digest digest #' @importFrom methods formalArgs hasArg +#' +#' @section Package Options: +#' * `"mlr3misc.warn_srcref"`: +#' Disable giving a warning during package loading when packages seem to be installed with the `"--with-keep.source"` +#' option by setting this option to `FALSE`. Defaults to `TRUE`. "_PACKAGE" .onLoad = function(libname, pkgname) { # nocov start + if (has_srcref(ids) && getOption("mlr3misc.warn_srcref", TRUE)) { + warningf(paste0("It looks like you installed packages with the '--with-keep.source' flag, which is discouraged.\n", # nolint + "You can find more information on this on the FAQ section of our website: https://mlr-org.com/faq.html\n", + "This warning can be disabled by setting the 'mlr3misc.warn_srcref' option to FALSE.\n")) + } backports::import(pkgname) } # nocov end diff --git a/man/mlr3misc-package.Rd b/man/mlr3misc-package.Rd index e33bdec1..435875ad 100644 --- a/man/mlr3misc-package.Rd +++ b/man/mlr3misc-package.Rd @@ -10,6 +10,15 @@ Frequently used helper functions and assertions used in 'mlr3' and its companion packages. Comes with helper functions for functional programming, for printing, to work with 'data.table', as well as some generally useful 'R6' classes. This package also supersedes the package 'BBmisc'. } +\section{Package Options}{ + +\itemize{ +\item \code{"mlr3misc.warn_srcref"}: +Disable giving a warning during package loading when packages seem to be installed with the \code{"--with-keep.source"} +option by setting this option to \code{FALSE}. Defaults to \code{TRUE}. +} +} + \seealso{ Useful links: \itemize{