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

object 'testthat_print' not found #1112

Closed
r2evans opened this issue Feb 4, 2021 · 6 comments · Fixed by #1184
Closed

object 'testthat_print' not found #1112

r2evans opened this issue Feb 4, 2021 · 6 comments · Fixed by #1184

Comments

@r2evans
Copy link

@r2evans r2evans commented Feb 4, 2021

devtools::document(...) # some local package
# Error in get(genname, envir = envir) : object 'testthat_print' not found

There is no code change required for this issue, just awareness of the source of the problem and its fix. Whether you blog it or tweet it or just keep this issue open and pinned for a while is up to you.

The Fix

Update testthat to 3.0.0 or newer.

If you haven't upgraded to rlang-0.4.10 yet, when you do, make sure you include "Suggests" in the dependencies= argument, as in

install.packages("rlang", dependencies = c("Depends", "Imports", "LinkingTo", "Suggests"))

(That includes 14 packages, it's possible one or more will be new to you.)

Background

Stemming from r-lib/devtools#2309, the issue arises because rlang can be updated while ignoring some of its dependencies.

Specifically, testthat::testthat_print was added (r-lib/testthat@07b19c8) before testthat3 was released. rlang started using it around the same time (bfb1d41), before it released rlang-0.4.10. So far, so good.

Unfortunately, testthat is in rlang's Suggests:, and the default for install.packages is dependencies=NA which only considers c("Depends", "Imports", "LinkingTo").

@lionel-
Copy link
Member

@lionel- lionel- commented Feb 5, 2021

Thanks for the heads up. I should probably have conditioned the registration on the testthat version.

@daattali
Copy link

@daattali daattali commented Mar 15, 2021

Thanks for catching this @r2evans ! I've also noticed all the "Error in get(genname, envir = envir) : object 'testthat_print' not found" messages lately and had no idea where they're coming from, finally decided to google it and found your info :)

@dapritchard
Copy link

@dapritchard dapritchard commented Mar 16, 2021

It can probably be inferred from @r2evans fantastic synopsis (thank you!), but for those who are in a situation where it is inconvenient or difficult to upgrade testthat, rlang 0.4.9 does not have this issue when used with previous versions of testthat.

@chasemc
Copy link

@chasemc chasemc commented Mar 24, 2021

Confirming that install.packages("rlang", dependencies = c("Depends", "Imports", "LinkingTo", "Suggests")) fixed it for me

@lionel-
Copy link
Member

@lionel- lionel- commented Apr 1, 2021

Thanks for documenting the issue and the solution @r2evans! Judging from the emojis this is a commonly googled annoyance.

Conditioning the registration on the testthat version is tricky because loading rlang should not load testthat. Maybe we should just ignore the registration request in s3_register() when the generic doesn't exist.

@lionel- lionel- added this to the next milestone Apr 19, 2021
lionel- added a commit to lionel-/rlang that referenced this issue Apr 28, 2021
lionel- added a commit to lionel-/rlang that referenced this issue Apr 28, 2021
PavanVaddady referenced this issue in PavanVaddady/modvizpop Jun 8, 2021
@tttongwang
Copy link

@tttongwang tttongwang commented Jun 10, 2021

Same issue! I just reinstalled the "testthat" pkg again and then the problem has gone.

remove.packages("testthat)
install.packages("testthat")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants