-
Notifications
You must be signed in to change notification settings - Fork 761
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
Unregister S3 methods explicitly #1001
Conversation
This is a workaround for a bug in base R. unloadNamespace does not unregister any S3 methods, so the promises are invalid if you install a new version of a package, try to unload and re-load the package. See https://stat.ethz.ch/pipermail/r-devel/2015-December/072150.html for more details and a reproducible example. This fixes the common lazy-load errors people often run into when trying to use devtools' install functions. Fixes r-lib#419, r-lib#503, r-lib#942, r-lib#631
While this is working for the test package and for devtools itself I have not tested it with any S4 packages to ensure it works there. I wanted to put it out there to get feedback on the implementation and see if there are any changes that need to be made. This error has long been a frustrating one for me, as it seemed to happen randomly, so finally figuring out what was going on and fixing it was pretty satisfying! |
Nice! If this is indeed a reliable fix that's compatible with S4 stuff, it'll be great to have those errors go away. |
200b631 uses a different approach to fixing the issue by simply forcing all of the promises explicitly before trying to unload rather than removing them. I also converted all of the previous uses of The previous commit was running into problems when trying to unload or reinstall devtools that do not occur using this method. I also tested this version on some S4 classes from Bioconductor and they seem to work without error. |
I like it. I think the only thing that's missing is a comment with the code explaining your reasoning above |
Thanks! |
For reference I opened a bug report about this (https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16644). BDR points out it is technically documented behavior, so there is unlikely to be a fix upstream. Personally I think the current behavior of Anyway this pull should fix the majority of the errors people experience when using devtools at least, thank you for merging it! |
@jimhester thanks for digging into this - it's been a hassle for ages! |
++ 💯 |
Btw. this makes me want to create an |
@jimhester bloody awesome. Best X-mas present this year. So sick and tired of the install-test-install-corrupt-db-quit-restart-crap-didn't-save-workspace cycle. |
I am still facing the same frustrating install-test-install-corrupt-db-quit-restart-crap-didn't-save-workspace cycle. Can one of the experts here document the solution or attach a link to Stack overflow where this is addressed to your satisfaction? Apologies if this is already resolved and documented somewhere else. |
This is a workaround for a bug in base R. unloadNamespace does not
unregister any S3 methods, so the promises are invalid if you install a
new version of a package, try to unload and re-load the package.
See https://stat.ethz.ch/pipermail/r-devel/2015-December/072150.html for
more details and a reproducible example.
This fixes the common lazy-load errors people often run into when trying
to use devtools' install functions.
Fixes #419, #503, #942, #631