Open Yunuuuu opened 3 years ago
@Yunuuuu Thank you for raising the issue, and for referencing the issue you filed with Tidyverse! We'll review it as we continue development of RStudio.
Also, can you please provide your system details?
RStudio Edition : <!-- Desktop or Server -->
RStudio Version :
OS Version :
R Version :
Thanks, Here is my system details:
RStudio Edition : Desktop
RStudio Version : Version 1.3.1073
OS Version : Windows 10 x64 (build 19041)
R Version : R version 4.0.3 (2020-10-10)
Sorry for the incomplete information for this problem, I'll detail it here.
I came across 12 identical warning messages when I open a R project with RStudio and load the tidyverse package. the warning messages is here:
> library(tidyverse)
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Found more than one class "atomicVector" in cache; using the first, from namespace 'Matrix'
Also defined by ‘Rmpfr’
Registered S3 methods overwritten by 'readr':
method from
format.col_spec vroom
print.col_spec vroom
print.collector vroom
print.date_names vroom
print.locale vroom
str.col_spec vroom
-- Attaching packages ------------------------ tidyverse 1.3.0 --
√ ggplot2 3.3.2 √ purrr 0.3.4
√ tibble 3.0.4 √ dplyr 1.0.2
√ tidyr 1.1.2 √ stringr 1.4.0
√ readr 1.4.0 √ forcats 0.5.0
-- Conflicts --------------------------- tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
when I use Ctrl+Shift+F10 to restart a R session and load tidyverse package again, these warning messages won't occur, I have tested several times and found that above warning messages only arose after below messages:
Registered S3 method overwritten by 'broom.mixed':
method from
tidy.gamlss broom
Registered S3 methods overwritten by 'lme4':
method from
cooks.distance.influence.merMod car
influence.merMod car
dfbeta.influence.merMod car
dfbetas.influence.merMod car
Registered S3 method overwritten by 'DescTools':
method from
reorder.factor gplots
and my sessioninfo is here:
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936
[2] LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] forcats_0.5.0 stringr_1.4.0 dplyr_1.0.2
[4] purrr_0.3.4 readr_1.4.0 tidyr_1.1.2
[7] tibble_3.0.4 ggplot2_3.3.2 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] rsvd_1.0.3 class_7.3-17
[3] ps_1.4.0 V8_3.2.0
[5] lmtest_0.9-38 rprojroot_1.3-2
[7] crayon_1.3.4 MASS_7.3-53
[9] PMCMRplus_1.6.0 nlme_3.1-149
[11] backports_1.1.10 reprex_0.3.0
[13] metafor_2.4-0 ggcorrplot_0.1.3
[15] GOSemSim_2.14.2 rlang_0.4.8
[17] XVector_0.28.0 readxl_1.3.1
[19] performance_0.5.0 irlba_2.3.3
[21] nloptr_1.2.2.2 extrafontdb_1.0
[23] callr_3.5.1 limma_3.44.3
[25] scater_1.16.2 extrafont_0.17
[27] BiocParallel_1.22.0 bit64_4.0.5
[29] loo_2.3.1 glue_1.4.2
[31] pheatmap_1.0.12 rstan_2.21.2
[33] parallel_4.0.3 processx_3.4.4
[35] vipor_0.4.5 AnnotationDbi_1.50.3
[37] BiocGenerics_0.34.0 ggstatsplot_0.6.1
[39] vsn_3.56.0 DOSE_3.14.0
[41] haven_2.3.1 tidyselect_1.1.0
[43] SummarizedExperiment_1.18.2 rio_0.5.16
[45] XML_3.99-0.5 zoo_1.8-8
[47] SuppDists_1.1-9.5 mc2d_0.1-18
[49] xtable_1.8-4 MatrixModels_0.4-1
[51] magrittr_1.5 cli_2.1.0
[53] zlibbioc_1.34.0 rstudioapi_0.11
[55] miniUI_0.1.1.1 fastmatch_1.1-0
[57] tinytex_0.26 shiny_1.5.0
[59] BiocSingular_1.4.0 xfun_0.18
[61] parameters_0.8.6 inline_0.3.16
[63] pkgbuild_1.1.0 bridgesampling_1.0-0
[65] caTools_1.18.0 tidygraph_1.2.0
[67] WRS2_1.1-0 expm_0.999-5
[69] Brobdingnag_1.2-6 ggrepel_0.8.2
[71] reshape_0.8.8 withr_2.3.0
[73] zeallot_0.1.0 ez_4.4-0
[75] rcompanion_2.3.25 bitops_1.0-6
[77] ggforce_0.3.2 plyr_1.8.6
[79] cellranger_1.1.0 e1071_1.7-4
[81] dqrng_0.2.1 coda_0.19-4
[83] RcppParallel_5.0.2 pillar_1.4.6
[85] gplots_3.1.0 Rmpfr_0.8-1
[87] multcomp_1.4-14 fs_1.5.0
[89] europepmc_0.4 paletteer_1.2.0
[91] DelayedMatrixStats_1.10.1 vctrs_0.3.4
[93] ellipsis_0.3.1 generics_0.0.2
[95] nortest_1.0-4 urltools_1.7.3
[97] tools_4.0.3 foreign_0.8-80
[99] beeswarm_0.2.3 munsell_0.5.0
[101] tweenr_1.0.1 fgsea_1.14.0
[103] DelayedArray_0.14.1 fastmap_1.0.1
[105] compiler_4.0.3 abind_1.4-5
[107] httpuv_1.5.4 DescTools_0.99.38
[109] ggExtra_0.9 GenomeInfoDbData_1.2.3
[111] gridExtra_2.3 edgeR_3.30.3
[113] lattice_0.20-41 later_1.1.0.1
[115] jsonlite_1.7.1 affy_1.66.0
[117] scales_1.1.1 gld_2.6.2
[119] pbapply_1.4-3 carData_3.0-4
[121] genefilter_1.70.0 promises_1.1.1
[123] car_3.0-10 BWStest_0.2.2
[125] tidyBF_0.3.0 metaBMA_0.6.3
[127] effectsize_0.3.3 pairwiseComparisons_3.0.0
[129] openxlsx_4.2.2 sandwich_3.0-0
[131] cowplot_1.1.0 statmod_1.4.34
[133] ipmisc_4.0.0 logspline_2.1.16
[135] Biobase_2.48.0 igraph_1.2.6
[137] survival_3.2-7 numDeriv_2016.8-1.1
[139] survivalROC_1.0.3 metaplus_0.7-11
[141] rstantools_2.1.1 htmltools_0.5.0
[143] memoise_1.1.0 fastGHQuad_1.0
[145] modeltools_0.2-23 locfit_1.5-9.4
[147] graphlayouts_0.7.0 IRanges_2.22.2
[149] here_0.1 viridisLite_0.3.0
[151] assertthat_0.2.1 gmp_0.6-1
[153] digest_0.6.25 mime_0.9
[155] Rttf2pt1_1.3.8 bayestestR_0.7.2
[157] RSQLite_2.2.1 LaplacesDemon_16.1.4
[159] Exact_2.1 data.table_1.13.0
[161] blob_1.2.1 S4Vectors_0.26.1
[163] preprocessCore_1.50.0 ggsci_2.9
[165] splines_4.0.3 rematch2_2.1.2
[167] Cairo_1.5-12.2 RCurl_1.98-1.2
[169] broom_0.7.1 hms_0.5.3
[171] modelr_0.1.8 colorspace_1.4-1
[173] BiocManager_1.30.10 ggbeeswarm_0.6.0
[175] GenomicRanges_1.40.0 libcoin_1.0-6
[177] broom.mixed_0.2.6 Rcpp_1.0.5
[179] coin_1.3-1 mvtnorm_1.1-1
[181] enrichplot_1.8.1 fansi_0.4.1
[183] multcompView_0.1-8 R6_2.4.1
[185] grid_4.0.3 ggridges_0.5.2
[187] lifecycle_0.2.0 EMT_1.1
[189] StanHeaders_2.21.0-6 rootSolve_1.8.2.1
[191] statsExpressions_0.5.1 zip_2.1.1
[193] BayesFactor_0.9.12-4.2 curl_4.3
[195] ggsignif_0.6.0 minqa_1.2.4
[197] affyio_1.58.0 broomExtra_4.0.6
[199] DO.db_2.9 Matrix_1.2-18
[201] qvalue_2.20.0 TH.data_1.0-10
[203] RColorBrewer_1.1-2 TMB_1.7.18
[205] polyclip_1.10-0 triebeard_0.3.0
[207] gridGraphics_0.5-0 rvest_0.3.6
[209] mgcv_1.8-33 insight_0.9.6
[211] lmom_2.8 bdsmatrix_1.3-4
[213] lubridate_1.7.9 codetools_0.2-16
[215] matrixStats_0.57.0 GO.db_3.11.4
[217] gtools_3.8.2 prettyunits_1.1.1
[219] dbplyr_1.4.4 SingleCellExperiment_1.10.1
[221] GenomeInfoDb_1.24.2 correlation_0.4.0
[223] gtable_0.3.0 DBI_1.1.0
[225] stats4_4.0.3 httr_1.4.2
[227] KernSmooth_2.23-17 stringi_1.5.3
[229] vroom_1.3.2 kSamples_1.2-9
[231] progress_1.2.2 msigdbr_7.2.1
[233] reshape2_1.4.4 farver_2.0.3
[235] annotate_1.66.0 viridis_0.5.1
[237] ggthemes_4.2.0 xml2_1.3.2
[239] rvcheck_0.1.8 bbmle_1.0.23.1
[241] boot_1.3-25 BiocNeighbors_1.6.0
[243] lme4_1.1-23 geneplotter_1.66.0
[245] ggplotify_0.0.5 DESeq2_1.28.1
[247] scran_1.16.0 bit_4.0.4
[249] scatterpie_0.1.5 ggraph_2.0.3
[251] pkgconfig_2.0.3
As it suggested, there were lots of packages loaded via a namespace (and not attached)
, I suspected there necessarily exist some associations between the warning messages after loading tidyverse package and the the message when opening a R project by RStudio (like Registered S3 method overwritten)
since the confusing message induced by loading tidyverse package only occurred when starting a R project in RStudio with a opening R script which containing the conflicting packages Matrix
.
I have found a question in RStudio community, which indicated RStudio automatically load packages when there are some opening R script. I think the message arising when I open a R project with RStudio (like Registered S3 method overwritten) was resulted from this, which subsequently resulted above problems. I don't know the details under these.
Again my System details
RStudio Edition : Desktop
RStudio Version : Version 1.3.1073
OS Version : Windows 10 x64 (build 19041)
R Version : R version 4.0.3 (2020-10-10)
Thanks for ur development of the RStudio.
Sorry to disturb, the behavior of RStudio, which automatically loads packages when starting RStudio with a opening R script, may lead to serious problems when a installed package was broken. Yesterday, RStudio in my computer cannot respond to anything when I started it, like this and this, I tried all these methods searched in Google, including but not limited to reinstalling R and Rstudio and resetting the setting preference of RStudio, the problem was still here. It made me crazy, I even reinstalled the windows system.
Subsequently, I found RStudio only suspend when I started it with a opening script which used a package named biomaRt
from Bioconductor, RStudio automatically loads this packages causing this problem. So I uninstalled the package biomaRt
, and started RStudio with the same Rproj
file again, it succeeded without any wrong.
We can localize problem easily when running code line by line compared with loading all used packages when starting RStudio. RStudio can provide a choice to cancel the behavior automatically loading the packages used in a opening R script, it really cause some strange problems sometimes.
Thanks for ur all work!
I have been wondering about this, too, although I don't believe it's caused any problems other than an annoying initial message at Rstudio startup ("Registered S3 methods overwritten..."). To echo what @Yunuuuu said, and to distill it, below are the steps I have found that can reproduce it simply. It seems to center around calling functions by package::function
rather than loading the package with library(package)
and then calling the desired function.
FWIW, I have Rstudio set to 'Restore previously open source documents at startup' but not to restore open projects or .Rdata at startup. My goal is to start 'fresh' with each session, which is why I was bothered.
My system: Rstudio Desktop 1.4.1103, R 4.0.3, Windows 10 x64 20H2 build 19042. Also reproduced on a Macbook Pro 16" running the same R and Rstudio versions
Steps to reproduce
length(loadedNamespaces())
-- in my case, a 'fresh start' is 11 - library(ggplot2)
and then the function ggplot()
- again, don't run this code.length(loadedNamespaces())
length(loadedNamespaces())
hasn't changed.ggplot2::ggplot()
-- now, without even running this code, refocus on the console and run loadedNamespaces()
and also check its length. If your experience is the same as mine, there are now many more namespaces loaded despite not having run any code at all.
Is this expected behavior? If a package isn't loaded with library(packages)
, is it necessary for dependencies to be loaded into namespaces for a user to run a function directly with package::function
?? I am only an intermediate user at this point and don't understand enough about environments to know whether this is expected or not. But, at the very least, it has the annoying effect that every time I open R with several previously-opened scripts, I see something like
Registered S3 methods overwritten by 'huge': method from plot.sim BDgraph print.sim BDgraph
Hopefully this is helpful in tackling this if it IS a bug, or clarifying what's happening on the backend if it's NOT a bug. I see that @ronblum tagged it as a bug previously, so I assume it's probably a bug. Thanks for your help!
Thanks for that helpful "fix" @teecrow !
I also experience this issue (OS: Majaro 21.1.0, R: 4.1.0, RStudio: 1.4.1717), and your tip helped me handle some serious issues that this bug (I'm assuming it's a bug) was causing!
So, also yes, FYI to the folks at RStudio (I suppose @ronblum would be someone to tag?), this is still an ongoing bug with RStudio.
My assumption is that RStudio's autocompletion system is triggering the load of the ggplot2 package. Does the issue go away if you disable RStudio's automatic auto-completion?
My assumption is that RStudio's autocompletion system is triggering the load of the ggplot2 package. Does the issue go away if you disable RStudio's automatic auto-completion?
It does not, unfortunately. Running sessionInfo()
first thing after startup, it shows a number of packages are loaded via a namespace, but not attached.
Few questions on this issue :
Using sessionInfo()
Base R shows 1 package under "loaded via a namespace (and not attached) :" compiler
RStudio | Tools | Global Options | General | Basic | Uncheck "Restore most recently opened project at startup"
Now, if you open RStudio directly, then it will show 2 packages only: compiler & tools
However, if you open RStudio using the ".Rproj" file, it will show multiple packages and related messages, warnings etc.
In that case, if you restart R then some of the packages and associated messages, warnings go away, but still many of them remain.
Please note, I am not an advanced user, so I might be wrong also.
I'm experiencing a similar issue. On startup of RStudio, I get the following message:
Registered S3 methods overwritten by 'registry':
method from
print.registry_field proxy
print.registry_entry proxy
It turns out that both the registry
and proxy
packages contain functions named print.registry_field
and print.registry_entry
, and the proxy
and registry
packages are being loaded via a namespace (and not attached)
as I can verify from sessionInfo()
.
I ensured that I have nothing in my .RData
file or .Rprofile
file or .Rhistory
file either in my home directory or default working directory, and I also turned off the Global Options "Restore most recently opened project at startup" and "Restore .RData into workspace at startup" and "Always save history (even when not saving .RData)."
Yet the message still appears on startup; and what is worse, it appears in the output of any RMarkdown document that I generate. The only way I can suppress the message is by deleting one of the two R packages registry
or proxy
, but this is not desirable as they are dependencies for other packages that I use regularly.
Surely RStudio IDE should give the user control over which packages are loaded via a namespace on startup?
There really needs to be a way to disable loading via namespace. I'm using the Groundhog package to control which versions I am using so that there no incompatibilities with different packages. But, if I start RStudio with my script open, or even just open the script later, RStudio loads a lot of packages via namespace which prevents Groundhog from managing those packages. There also doesn't seem to be any easy way to unload them (because of dependencies in the order they have to be unloaded) and they seem to reload as soon as you run other commands from the script. The solution for now appears to be splitting into two scripts, one which loads all the packages (but doesn't use them to avoid loading via namespace) and a second which contains the analysis. But this is fiddly and far from ideal.
I'll raise this for review. BTW, one of the ways in which we re-review and reconsider issues is by the number of upvotes in the original post. We also look for posts that have a lot of of comments on it, but that's a little more complicated. So I recommend folks affected by and interested in this also add 👍 to the original post.
(I ran across this because I get every email notification, even if I just said thank you at the start. 🙂 )
Note: Whenever a file is opened in an editor, the packages used in that file with format package::function
will be loaded via namespace when that file is opened WHEN R code diagnostics are turned on. If R code diagnostics are off, then no loading via namespace occurs. Editing the file will potentially cause packages to be loaded via namespace due to autocomplete.
This occurs in the context of RStudio projects, as well as outside of any project. If a project is opened with files already open in the editor, then these packages will be loaded via namespace as soon as the project is opened, which depending on the user's configuration may be as soon as they start RStudio. This behavior has pretty much always existed in the IDE, and is by design, but can cause problems for many users; therefore it could be helpful to have a global option to disable this behavior upon files being open in the editor.
Code diagnostics will load packages via namespace for any file that is open and in focus in the editor; if there are package::function
calls in the focused file and diagnostics are on then that package and its dependencies will be loaded via namespace. Autocomplete will also load packages via namespace if the user begins typing a package name/function in the editor or console.
purrr::map(1:5, print) # if file is open and in focus, purrr and dependencies will be loaded
library(ggplot2) # ggplot2 will not automatically be loaded when file is open
geom_ # if I start typing the name of a function, and I hit tab to use autocomplete, then ggplot2 and dependencies will be loaded
I have just confirmed what @jgutman describes. In summary, to disable the behaviour, you must change the following settings in global options:
I just did a quick test and that seemed to work fine for my needs. Thank you.
I have just confirmed what @jgutman describes. In summary, to disable the behaviour, you must change the following settings in global options:
- Disable "Show code completions", in "/Global options/Code/Completion"
- Disable "Show diagnostics for R", in "/Global options/Code/Diagnostics"
This works. But I have found that disabling code completion is not necessary(I like auto-completion :-) ). Only disabling R diagnostics, and disabling all "restore"options in Global options > General > Basic, is enough. Even when switching between scripts the namespace will now no longer be automatically reloaded.
It may introduce some problems when using RStudio to open a R project with several opening R scripts, for RStudio will
load packages via namespace
.As I mentioned here, I found those warning messages only occur following these messages induced by RStudio when starting a RProject.
Registered S3 method overwritten by 'broom.mixed': method from tidy.gamlss broom Registered S3 methods overwritten by 'lme4': method from cooks.distance.influence.merMod car influence.merMod car dfbeta.influence.merMod car dfbetas.influence.merMod car Registered S3 method overwritten by 'DescTools': method from
reorder.factor gplots
Thanks for ur help