r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.37k stars 753 forks source link

devtools::load_all errors 'Error: Invalid mset' and 'Error in loadedNamespaces() : bad hash table contents' and others #2413

Closed woropajj closed 2 years ago

woropajj commented 2 years ago

If I want to execute more than one line of code and some of them contain devtools::load_all, sometimes I will get errors such as: Error: Invalid mset Error in loadedNamespaces() : bad hash table contents

I will also get errors like:

[369186:369187:20220304,104510.797881:ERROR file_io_posix.cc:148] open /home/kuba/.r/crashpad_database/pending/97a97a24-d12c-4146-8b6e-bf99866681fc.lock: File exists (17)
[369186:369187:20220304,104510.798068:ERROR directory_reader_posix.cc:42] opendir: No such file or directory (2)
[369186:369186:20220304,104510.800791:ERROR process_memory_range.cc:86] read out of range
[369186:369186:20220304,104510.800807:ERROR elf_image_reader.cc:558] missing nul-terminator
[369186:369186:20220304,104510.801016:ERROR elf_dynamic_array_reader.h:61] tag not found
[369186:369186:20220304,104510.805504:ERROR elf_dynamic_array_reader.h:61] tag not found
Error in structure(.Call(C_Rmd5, files), names = files) : 
  '...' used in an incorrect context
Error in order(y) : 
  434 arguments passed to .Internal(sorted_fpass) which requires 3

What is happening? How can I solve this? What triggers these errors?

I also get nearly constant 'fatal error' after CTRL+SHIFT+F10 (session restart) in RStudio.

Session info below.

> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.1.2 (2021-11-01)
 os       Ubuntu 20.04.4 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Warsaw
 date     2022-03-04
 rstudio  2021.09.2+382 Ghost Orchid (desktop)
 pandoc   NA

─ Packages ───────────────────────────────────────────────────────────────────
 package     * version  date (UTC) lib source
 cli           3.1.0    2021-10-27 [2] CRAN (R 4.1.2)
 crayon        1.4.2    2021-10-29 [2] CRAN (R 4.1.2)
 logging     * 0.10-108 2019-07-14 [1] CRAN (R 4.1.2)
 sessioninfo   1.2.2    2021-12-06 [2] CRAN (R 4.1.2)

 [1] /home/kuba/Documents/projects/auto-replenishment-2-r4/modules/deployment/sbox
 [2] /home/kuba/Documents/projects/auto-replenishment-2-r4/modules/deployment/libs
 [3] /home/kuba/R/x86_64-pc-linux-gnu-library/4.1
 [4] /usr/local/lib/R/site-library
 [5] /usr/lib/R/site-library
 [6] /usr/lib/R/library

──────────────────────────────────────────────────────────────────────────────
msberends commented 2 years ago

I have the exact same thing, but my error messages vary a lot. The most annoying thing is that I cannot reproduce it. I get errors in multiple projects by running devtools::load_all(), and it seems most likely that they are caused by a recent update of devtools.

Sometimes I get these:

Error: .onLoad failed in loadNamespace() for 'devtools', details:
  call: options()
  error: Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'NULL'

Sometimes these (always 3 same lines):

*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation

Sometimes these:

Error in .getClassesFromCache(Class) : 
  class should be either a character-string name or a class definition

Or these:

Error in is(f, "groupGenericFunction") : object 'class2Def' not found

And sometimes the errors raised in above post. It started roughly 4-5 weeks ago.

Restarting the R sessions works, re-running devtools::load_all() works (sometimes by calling it 5-10 times, then it suddenly works), as does installing and running the package of the project I'm working in.

I'm on devtools 2.4.3 on macOS 12.12.1, R 4.1.2 and RStudio 2021.09.1 (build 372).

woropajj commented 2 years ago

I also get *** recursive gc invocation but I thought it was unrelated to devtools.

msberends commented 2 years ago

I first thought that too, but I only get it when running devtools::load_all(), so...

jennybc commented 2 years ago

There was a period of time where there was an RStudio bug that presented like this. devtools (or pkgload) was not the root cause, but it was very likely to be the closest bystander that tickled the bug, so it certainly felt like devtools was the problem.

https://github.com/rstudio/rstudio/issues/10040

I recommend updating RStudio and seeing if the problem goes away. I know it did for me. This is the current version of RStudio and it's what I'm on: 2022.02.0+443 Prairie Trillium (desktop).

msberends commented 2 years ago

Ah, many thanks! I'll try it out immediately. Didn't think of RStudio being the culprit, though I now question myself whether problems didn't start after I updated last time 🤔

Oh well, sometimes these things happen!