Revert back to s3_register()
#347
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@hadley you owe me a coffee at useR for this headache 😛
#310 swapped us from
s3_register()
to base R's@exportS3Method
. Unfortunately, @lionel- and I have re-discovered that we absolutely cannot use this feature right now, asisNamespaceLoaded()
incorrectly returnsTRUE
at the wrong times, which has a bad interaction with base R's form of lazy registration.This PR reverts us back to
s3_register()
.If you are in the vctrs project and you
load_all()
with CRAN glue, this happens even when you already have glue installed:Screen.Recording.2025-08-04.at.12.33.53.PM.mov
With advanced debugging turned on using
Sys.setenv("_R_TRACE_LOADNAMESPACE_" = "4")
, we seeWhat we see here is:
load_all()
registerS3Methods()
to run for gluevctrs::vec_cast()
method. Ideally this runs once vctrs is fully loaded. Instead,isNamespaceLoaded("vctrs")
returnsTRUE
andregisterS3Methods()
tries to immediately register the method forvec_cast()
, which is a generic that does not exist yet. This causes glue to fail to load and we get an error which seems to get swallowed by someone (can't tell by who) when running throughload_all()
, but we can see it in my image below.When running tests in parallel, this is even more confusing because we automatically answer
"no"
tocheck_installed()
's request (because we are in a subprocess) and we get: