Home Comments Thread
New Thread

Deprecating xfun::isFALSE() | /en/2023/02/xfun-isfalse/

giscus giscus 2023-02-08 00:37:38

Deprecating xfun::isFALSE()

Base R has had the function isTRUE() for many years, and I had wished for a few years that there were an isFALSE(), too. I had used identical(x, FALSE) many times before I added it to the first …

https://yihui.org/en/2023/02/xfun-isfalse/

👍 2

7 Comments

mingxin-zhang mingxin-zhang 2023-03-19 15:52:28

谢老师您好,感谢您在RMarkdorn等诸多领域的贡献!我是一名来自中国的学生,希望向您请教一个问题:我最近在写一个计量经济学领域的R package,我比较确定我所写的函数没有用到xfun::isFALSE,但是在我进行devtolls::check()时,总是会返回错误
Error(s) in re-building vignettes:
Error: processing vignette 'Introduction_to_JTZ.Rmd' failed with diagnostics:
The function xfun::isFALSE() will be deprecated in the future. Please consider using base::isFALSE(x) or identical(x, FALSE) instead.
我完全理解这个错误的含义,但是我实在搞不明白究竟是哪一个函数使用了xfun::isFALSE。
所以我想向您请教:是否有直接在所有函数中替换xfun::isFALSE的方式?

yihui yihui 2023-03-19 20:12:29

首先保证你所有的 R 包都已经升级至最新版本,如果已经升级所有包还是有这个错误,那么手工运行 rmarkdown::render("Introduction_to_JTZ.Rmd"),出错后看 traceback(),看是哪个函数调用了 xfun::isFALSE()

liuyanguu liuyanguu 2023-06-30 10:52:42

I got a similar issue and solved it by removing install.packages() or library() from the Rmd.

liuyanguu liuyanguu 2023-06-30 13:21:09

Actually not solved. Running rmarkdown::render("my_vignette.Rmd") is fine, but the devtools::check() returns the same error.

icasas icasas 2023-08-16 17:11:24

Hello. I have the same problem. The worst is that I do not know what I should change of my .Rmd to not call xfun::isFALSE(). Any help?
Thanks a lot.

yihui yihui 2023-08-16 18:22:56

When in doubt, try to update software packages.

update.packages(ask = FALSE, checkBuilt = TRUE)
matloff matloff 2023-09-06 06:44:17

Same problem. Re-installed devtools, to no avail.

yihui yihui 2023-09-06 14:57:46

Re-installing devtools probably won't help, since it doesn't use xfun::isFALSE(). If you can find out where the error came from (e.g., from traceback()), you need to update that package, otherwise I'd suggest you update all packages:

update.packages(ask = FALSE, checkBuilt = TRUE)
matloff matloff 2023-09-06 16:15:08

Right, but there may be an indirect call. Anyway, of course I tried traceback(), but e.g. calling it from devtools::check(), I get the message "No traceback available." Note: It MATTERS; I'm trying to submit a major package to CRAN.

yihui yihui 2023-09-06 16:32:32

Have you tried updating all packages as mentioned above?

matloff matloff 2023-09-06 16:41:05

I started doing so last night, but it wasn't done after an hour, and I needed to shut down the machine. (PC running Linux. All seems to work on my Mac.) I'm going to finish the updates today, will let you know if it helps.

yihui yihui 2023-09-06 17:14:05

I think the problem is from one of your outdated packages. Normally CRAN uses the latest versions of packages when checking your package, so this problem is unlikely to prevent you from passing CRAN's auto-check.

matloff matloff 2023-09-06 17:22:32

As always, I salute the CRAN reviewing team. They diligently perform a thankless task. But don't they have their own internal checks, beyond R CMD check -cran? As we all know, one's package can pass the later check with flying colors, only to have the CRAN team say, "We see that....," pointing to something wrong that didn't emerge in the above test?

matloff matloff 2023-09-07 03:11:21

Good news, Yihui! Updating the packages seems to have worked. At least the error message no longer appears, and "post hoc ergo propter hoc." :-) Thanks very much.

yihui yihui 2023-09-07 13:29:12

Good to know! You are welcome!

matloff matloff 2023-09-19 16:49:30

Unfortunately, there is a postscript. :-( With the "updated" files (reason for the quote marks below), I started getting error messages from R CMD check --as-cran "there is no package 'tufte'" regarding the vignettes. This on both Mac and Linux. But I also had a brand new Mac, and after installing everything, it ran fine, no error messages. So apparently "updating" had not been thorough, or something. Anyway, I built on the new machine, and submitted to CRAN. But sure enough, Uwe's message then informed me that the missing-tufte problem had occurred on both Windows and Debian. Were the CRAN machines also not updated?

Of course, I can remove the tufte stuff from the vignettes, but as you can understand :-) I hate to do so. Great package!

The package, BTW, is at github.com/matloff/qeML, if you are curious.

yihui yihui 2023-09-19 17:14:18

I don't think this is relevant to updating packages. R CMD check --as-cran is quite strict about package dependencies declared in your DESCRIPTION file. Basically any package that you use in your package (including vignettes) must be declared in DESCRIPTION. You didn't declare tufte: https://github.com/matloff/qeML/blob/133b1587/DESCRIPTION Therefore no matter which platform you use, R CME check --as-cran should signal the problem. I don't know what you ran exactly on the new Mac, but in theory, it should give you the same note.

You can look for _R_CHECK_SUGGESTS_ONLY_ in the R-ints manual for an official explanation.

matloff matloff 2023-09-19 17:21:59

Ah, so even vignettes' use of libraries must be stated in the DESCRIPTION file. I said I had "tried everything," but this never occurred to me. Thanks!

kenahoo kenahoo 2023-11-07 22:27:09

Hi @yihui, we hit this issue in our company's pipelines because we run R CMD check in our build processes for our locally-developed code. Those pipelines started failing with the error you mention.

This doesn't seem like a "deprecation", it's a backward incompatibility, because things that used to work no longer work, right? A deprecation would give people a period of time to switch off the implementation, emitting a warning (or not) in the meantime.

Aside from that - is there any real pressing need to deprecate/remove this? Instead of removing it, could it just be turned into a pass-through to base::isFALSE()? That would probably be a lot gentler to people's existing pipelines.

yihui yihui 2023-11-07 23:02:06

Sorry about the trouble! The deprecation was planned last year (yihui/xfun#67) and started on Jan 31 this year: yihui/xfun@51de443#diff-60bef5af43a1bd541299ce9bceeb226afb23deaa5e637b145c85e05ffd552b0c

Did you use xfun::isFALSE directly in your code? If so, searching and replacing them with base::isFALSE probably works, but these two functions are not strictly equivalent, which is one of the pressing reasons to deprecate the former: it's too confusing to have two functions with the same name but not equivalent. Yes, I could simply turn it to a pass-through to base::isFALSE, but the latter didn't exist until R 3.5.0, so I had to wait for R 3.5.0 to be "old enough".

I understand that deprecating a function can be frustrating to users, so sometimes I would wait for two or three years before turning a warning to an error. For the case of xfun::isFALSE, I thought it should be straightforward enough for users to make the switch, so I didn't plan for a long period of deprecation but started to throw the error only during R CMD check (and emit warnings in other cases). I could emit a warning instead, but R CMD check will muffle messages so you probably will never notice it.

Anyway, if this problem is too difficult for you to fix, I can definitely provide something like an environment variable to change the error into a warning during R CMD check (but it will still become an error someday, like a couple of years later). Please let me know if that would work for you. Thanks!

kenahoo kenahoo 2023-11-07 23:26:24

Thanks for your reply! It's not totally clear to me which code had the errant isFALSE() in it, but it wasn't the package being R CMD checked. The user whose pipeline failed reported to me that when he upgraded various packages the problem went away, and I think the culprit was probably either rmarkdown or knitr. Those are two of the packages he upgraded, at least. I haven't found the actual smoking gun, and the user's pipeline is now passing so he's not troubleshooting anymore (but there will likely be other users whose pipelines break in the same way).

Specifically, I think the fix I need to make now is to identify the package that was causing the call to isFALSE(), and rebuild the Docker image that my users use in their pipelines so it starts out with a version of that package that doesn't cause the problem. It might most likely be knitr, that was installed at version 1.39 in the base image. Does that seem like it might be correct?

yihui yihui 2023-11-08 01:06:16

when he upgraded various packages the problem went away

That's what I suggested in the beginning of this post---do a full update of packages. The most likely way to run into this problem is a partial update, e.g., updating xfun but not knitr. I have removed the use of xfun::isFALSE() in all packages that I maintain last year (e.g., yihui/knitr@ccb07c4), and no CRAN packages should be affected by the deprecation of xfun::isFALSE (this is guaranteed by checking reverse dependencies).

In short, if you are using the latest (or relatively recent) versions of CRAN packages, you shouldn't be affected by the deprecation of xfun::isFALSE.

kenahoo kenahoo 2023-11-08 16:16:46

In our setting, which is not just a bunch of individual workstations, but a set of deployed production applications, we generally need to control the deploy environment much more carefully than that, so we can't generally just "do a full update of packages". That's why I need to try to understand which specific pieces need to be updated, and do those in a controlled fashion.

yihui yihui 2023-11-08 16:32:47

If you desire the controlled fashion, I think using packages like renv would be a much better solution, otherwise it would be too difficult to know which versions of packages work or don't work with which versions of other packages.

kenahoo kenahoo 2023-11-08 18:45:10

Yes, we do use renv when feasible.

laceto laceto 2023-11-08 20:56:10

Hi, I cannot understand what is going in my package. if I run the cmd check from workbench's console I did not get any error while when running the check into the pipeline to create and pull the package to package manager I get the error. can you tell me why? thank you

yihui yihui 2023-11-08 21:06:13

Have you read the note in the beginning of this post? https://yihui.org/en/2023/02/xfun-isfalse/

laceto laceto 2023-11-08 21:11:15

yes, I've updated already all packages and checked that this funs is not used anywhere but the error persists.

yihui yihui 2023-11-08 22:24:44

I'm reasonably sure that certain packages are still outdated. Here is how you can check:

pkgs = tools::dependsOnPkgs('xfun', dependencies = 'all', recursive = FALSE)
vers = sapply(pkgs, function(p) as.character(packageVersion(p)))
vers

The results depend on the packages you installed in the system. Here are some of my package versions:

blogdown   bookdown      highr      knitr   markdown Rd2roxygen  rmarkdown    rticles      servr    tinytex 
  "1.18"     "0.36"     "0.10"     "1.45"     "1.11"     "1.14"     "2.25"     "0.25"     "0.27"     "0.48" 

You can run the above code in the system where you got the error, and see if the packages are truly up-to-date.

I don't know what your "pipeline" means or is, but please note that R can have multiple library paths (.libPaths()) and you could install multiple copies and different versions of a package into libraries with different paths. R CMD check will ignore library paths you set in .Rprofile but respect those set in .Renviron.

yihui yihui 2023-11-08 23:40:31

I just made a change in xfun so that you will know better which packages are outdated in the error message if you install the dev version:

remotes::install_github('yihui/xfun')
imran2160 imran2160 2025-02-13 17:21:02

--QUOTE

processing file: CRUD_dl.Rmd
|. | 2%
ordinary text without R code

|... | 4%
label: setup (with options)
List of 1
$ include: logi FALSE

Quitting from lines 15-18 (CRUD_dl.Rmd)
Error in isFALSE(options$results) :
The function xfun::isFALSE() has been deprecated. Please update the possibly outdated package(s): knitr 1.41, rmarkdown 2.19. You may see https://yihui.org/en/2023/02/xfun-isfalse/ for more info.
Calls: ... process_group.block -> call_block -> fix_options -> isFALSE
Execution halted

--UNQOUTE

I am getting the above QUOTED error while trying to generate an HTML file; kindly help.

yihui yihui 2025-02-13 23:06:43

The help has already been provided in the error message. Please read the error message and follow the instruction.

imran2160 imran2160 2025-02-13 23:09:25

The help has already been provided in the error message. Please read the error message and follow the instruction.

I have tried updating packages; it is installing only the binay. Its not not installing.

yihui yihui 2025-02-14 00:17:19

Your R version is probably too old (please provide sessionInfo() so we don't need to guess), and CRAN doesn't provide binaries for too old R versions. Please consider upgrading R, or installing packages from source or from R-universe:

install.packages(
  c('xfun', 'knitr', 'rmarkdown'),
  repos = c('https://yihui.r-universe.dev', 'https://rstudio.r-universe.dev', getOption('repos'))
)
imran2160 imran2160 2025-02-14 00:56:58

Your R version is probably too old (please provide sessionInfo() so we don't need to guess), and CRAN doesn't provide binaries for too old R versions. Please consider upgrading R, or installing packages from source or from R-universe:

install.packages(
  c('xfun', 'knitr', 'rmarkdown'),
  repos = c('https://yihui.r-universe.dev', 'https://rstudio.r-universe.dev', getOption('repos'))
)

my version is 4.2, i have installed 4.4 now and releated Rtools. thanks for the alternate options.

Sign in to join the discussion

Sign in with GitHub