RStudio session crashes on running nloptr - r

I am trying to run a non-linear constrained optimisation using the nloptr package. When I run the optimisation the Rstudio session crashes. The log files don't seem to capture this crash. The last log file is from some weeks back. The diagnostics report also shows this as the last error:
31 Jul 2021 12:49:50 [rsession-dhruvakaggarwal] ERROR system error 2
(No such file or directory)
[path=/Volumes/GoogleDrive/.shortcut-targets-by-id/1uELoLTtQ0-MVlZj5loA1k2gZAdJlDODV/SEA-LBL/Dhruvak];
OCCURRED AT: rstudio::core::Error
rstudio::core::FilePath::makeCurrentPath(bool) const
/Users/rstudio/rstudio/src/cpp/core/FilePath.cpp:1037; LOGGED FROM:
virtual void
rstudio::session::modules::rmarkdown::notebook::ChunkExecContext::connect()
/Users/rstudio/rstudio/src/cpp/session/modules/rmarkdown/NotebookExec.cpp:202
When I request logs it shows this:
The session does not crash when the optimisation problem is run on a substantially smaller sample dataset, which might point to limited RAM on the system? I'm running it on an 8GB system, but I've tried it on a 32GB system and it still crashes. Curiously, it doesn't crash on another 16GB system.
Session info:
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 compiler_4.0.0 pillar_1.6.2 bitops_1.0-6 tools_4.0.0 lifecycle_1.0.0 tibble_3.0.1
[8] gtable_0.3.0 lattice_0.20-41 pkgconfig_2.0.3 rlang_0.4.11 Matrix_1.2-18 cli_2.0.2 DBI_1.1.0
[15] rstudioapi_0.11 binman_0.1.1 dplyr_1.0.7 generics_0.0.2 vctrs_0.3.8 askpass_1.1 mitools_2.4
[22] caTools_1.18.0 tidyselect_1.1.0 grid_4.0.0 glue_1.4.0 R6_2.4.1 processx_3.4.2 fansi_0.4.1
[29] XML_3.99-0.3 survival_3.1-12 RSelenium_1.7.7 purrr_0.3.4 ggplot2_3.3.0 semver_0.2.0 magrittr_1.5
[36] ps_1.3.2 scales_1.1.0 ellipsis_0.3.2 splines_4.0.0 assertthat_0.2.1 colorspace_1.4-1 utf8_1.1.4
[43] survey_4.0 openssl_1.4.1 munsell_0.5.0 wdman_0.2.5 crayon_1.3.4
I am unable to figure out the cause for this. Please help.

Related

Rstudio server crashes when loading large seurat object

I am working on the latest bioconductor_docker r-studio server (link) and I want to load a seurat object (size = 1.9GB) like
library(Seurat)
mca <- readRDS(<path_2_seurat_file>)
but I get the error:
19 Jul 2021 09:20:57 [rsession-rstudio] ERROR session hadabend; LOGGED FROM: rstudio::core::Error {anonymous}::rInit(const rstudio::r::session::RInitInfo&) src/cpp/session/SessionMain.cpp:675
I think this error might be due to some memory usage restriction as:
I can load this data on the r-studio on my computer (even when the docker container is running). The R session-info between the docker container and my computer (MacOS Cathalina.10.15.7) are similar.
I can load smaller seurat object on the rstudio-server (docker container).
So I tried running the docker container with the parameters -it --memory="8g" but it did not solve the problem.
Do you know any solutions to this problem or know how I could find a solution?
Here are supplementary information about the session:
Rstudio-server version: Version 1.4.1717
SessionInfo:
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=C LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] SeuratObject_4.0.2 Seurat_4.0.3
loaded via a namespace (and not attached):
[1] nlme_3.1-152 matrixStats_0.59.0 spatstat.sparse_2.0-0 RcppAnnoy_0.0.18 RColorBrewer_1.1-2 httr_1.4.2
[7] sctransform_0.3.2 tools_4.1.0 utf8_1.2.1 R6_2.5.0 irlba_2.3.3 rpart_4.1-15
[13] KernSmooth_2.23-20 uwot_0.1.10 mgcv_1.8-36 DBI_1.1.1 lazyeval_0.2.2 colorspace_2.0-2
[19] tidyselect_1.1.1 gridExtra_2.3 compiler_4.1.0 cli_3.0.0 plotly_4.9.4.1 scales_1.1.1
[25] lmtest_0.9-38 spatstat.data_2.1-0 ggridges_0.5.3 pbapply_1.4-3 goftest_1.2-2 stringr_1.4.0
[31] digest_0.6.27 spatstat.utils_2.2-0 pkgconfig_2.0.3 htmltools_0.5.1.1 parallelly_1.26.1 fastmap_1.1.0
[37] htmlwidgets_1.5.3 rlang_0.4.11 rstudioapi_0.13 shiny_1.6.0 generics_0.1.0 zoo_1.8-9
[43] jsonlite_1.7.2 ica_1.0-2 dplyr_1.0.7 magrittr_2.0.1 patchwork_1.1.1 Matrix_1.3-4
[49] Rcpp_1.0.7 munsell_0.5.0 fansi_0.5.0 abind_1.4-5 reticulate_1.20 lifecycle_1.0.0
[55] stringi_1.6.2 MASS_7.3-54 Rtsne_0.15 plyr_1.8.6 grid_4.1.0 parallel_4.1.0
[61] listenv_0.8.0 promises_1.2.0.1 ggrepel_0.9.1 crayon_1.4.1 miniUI_0.1.1.1 deldir_0.2-10
[67] lattice_0.20-44 cowplot_1.1.1 splines_4.1.0 tensor_1.5 pillar_1.6.1 igraph_1.2.6
[73] spatstat.geom_2.2-0 future.apply_1.7.0 reshape2_1.4.4 codetools_0.2-18 leiden_0.3.8 glue_1.4.2
[79] data.table_1.14.0 png_0.1-7 vctrs_0.3.8 httpuv_1.6.1 gtable_0.3.0 RANN_2.6.1
[85] purrr_0.3.4 spatstat.core_2.2-0 polyclip_1.10-0 tidyr_1.1.3 scattermore_0.7 future_1.21.0
[91] assertthat_0.2.1 ggplot2_3.3.5 mime_0.11 xtable_1.8-4 later_1.2.0 survival_3.2-11
[97] viridisLite_0.4.0 tibble_3.1.2 cluster_2.1.2 globals_0.14.0 fitdistrplus_1.1-5 ellipsis_0.3.2
[103] ROCR_1.0-11
Update 1
When trying to read a cell_data_set object I now get the same error as before + another error.
library(monocle3)
cds <- readRDS(<path_to_cell_data_set_file>)
19 Jul 2021 12:50:10 [rsession-rstudio] ERROR session hadabend; LOGGED FROM: rstudio::core::Error {anonymous}::rInit(const rstudio::r::session::RInitInfo&) src/cpp/session/SessionMain.cpp:675
19 Jul 2021 12:50:10 [rsession-rstudio] ERROR system error 2 (No such file or directory) [path:/home/rstudio/.local/share/rstudio/sessions/active/session-975447f0/suspended-session-data/search_path/search_path_elements]; OCCURRED AT rstudio::core::Error rstudio::core::FilePath::openForRead(std::shared_ptrstd::basic_istream<char >&) const src/cpp/shared_core/FilePath.cpp:1427; LOGGED FROM: void rstudio::r::session::{anonymous}::reportDeferredDeserializationError(const rstudio::core::Error&) src/cpp/r/session/RInit.cpp:63
I also check (with file.exists()) and the file <path_to_cell_data_set_file> exits.
After some digging around I found this post on how to assign more memory to docker container.
I though that by adding -m 8g or -it --memory="8g" to the docker run command was enough to increase the memory limits. However, after typing docker stats, I found that my memory limit was stuck at 2GB.
I followed the instructions on this link which lead me to increase the memory limits in the > docker > Preferences > resources > Memory.
Now everything works like clockwork.

shiny runs undesirable scripts on R folder

This issue shook me. Lets a minimal reproducible example:
On RStudio, create a New Project... Choose Shiny Web App. Check that sample app runs well.
Create inside the standard R folder, to put all your *.R scripts.
Create a dummy script inside the R folder that fails, but you do not want run yet. For example
str(do_not_exist) ## foo.R
4.Run the App again. Now, the App fails
> runApp()
Error in str(do_not_exist) : objeto 'do_not_exist' no encontrado
Why Shiny runs undesirable scripts? They are OUT of the root directory.
I am not finding ways to save scripts that are not functions within the project.
This is my R Session
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Argentina.1252 LC_CTYPE=Spanish_Argentina.1252
[3] LC_MONETARY=Spanish_Argentina.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Argentina.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tidyr_1.1.3 dplyr_1.0.5 openxlsx_4.2.3.9000 shiny_1.6.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 magrittr_2.0.1 tidyselect_1.1.0 xtable_1.8-4
[5] R6_2.5.0 rlang_0.4.10 fastmap_1.1.0 fansi_0.4.2
[9] tools_4.0.5 utf8_1.2.1 DBI_1.1.1 withr_2.4.2
[13] htmltools_0.5.1.1 ellipsis_0.3.1 assertthat_0.2.1 digest_0.6.27
[17] tibble_3.1.1 lifecycle_1.0.0 crayon_1.4.1 zip_2.1.1
[21] purrr_0.3.4 later_1.1.0.1 vctrs_0.3.7 promises_1.2.0.1
[25] glue_1.4.2 mime_0.10 stringi_1.5.3 compiler_4.0.5
[29] pillar_1.6.0 generics_0.1.0 httpuv_1.5.5 pkgconfig_2.0.3
See here. One option is options(shiny.autoload.r = FALSE).

RStudio - Markdown Crash: Error in (function (srcref) : unimplemented type (29) in 'eval'

My RStudio crashed a number of times with the following error:
Error in (function (srcref) : unimplemented type (29) in 'eval'
The similarities where this has happened were:
I was working in a Markdown Notebook
I believe it was always when I selected the "Run all chunks above" command
I had run some code chunks in the current session before (so it wasn't upon starting work)
The error was always displayed just before the RStudio session aborted. I lose all my data and variables in the environment, but most of the code seems to be recoverable.
Anyone with an idea of what might cause this or how to deal with it?
Here my SessionInfo
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.12.8 forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5 purrr_0.3.4 readr_1.3.1
[7] tidyr_1.0.2 tibble_3.0.0 ggplot2_3.3.0 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 cellranger_1.1.0 pillar_1.4.3 compiler_4.0.0 dbplyr_1.4.3 tools_4.0.0 packrat_0.5.0
[8] lubridate_1.7.8 jsonlite_1.6.1 lifecycle_0.2.0 nlme_3.1-147 gtable_0.3.0 lattice_0.20-41 pkgconfig_2.0.3
[15] rlang_0.4.5 reprex_0.3.0 cli_2.0.2 DBI_1.1.0 rstudioapi_0.11 haven_2.2.0 xfun_0.13
[22] withr_2.2.0 xml2_1.3.1 httr_1.4.1 knitr_1.28 fs_1.4.1 hms_0.5.3 generics_0.0.2
[29] vctrs_0.2.4 grid_4.0.0 tidyselect_1.0.0 glue_1.4.0 R6_2.4.1 fansi_0.4.1 readxl_1.3.1
[36] modelr_0.1.6 magrittr_1.5 backports_1.1.6 scales_1.1.0 ellipsis_0.3.0 rvest_0.3.5 assertthat_0.2.1
[43] colorspace_1.4-1 stringi_1.4.6 munsell_0.5.0 broom_0.5.6 crayon_1.3.4
I sadly can't give you a reproducible example, but this is a screenshot of the last time it happened:
And the next time following a fairly simple ggplot command:
You might try updating Rstudio.
I had similar messages that started to occur after I updated to version 4.0.0 of R. These errors were occurring with code that presented no problems on previous versions of R. I could run the code line by line with Ctrl-Enter with no error, but running the whole chunk would be a problem.
The issue went away when I updated Rstudio from Version 1.1.463 to 1.2.5042.

Double question mark (??) help search not working in RStudio (and RStudio only)

strange behaviour I noticed in my RStudio installation:
Help search via the double question mark (e.g., ??gg) does not work in RStudio. It gives me "No results found" in the Help pane.
Help search via the upper search field in the Help pane works as intended and returns results for the example search above.
?? works in the Mac OS R GUI ("R.app"), it opens a browser tab with the results page.
Single question mark ? works also in RStudio (but of course only with exact matches to names).
Does anybody know how to resolve this? Thanks!
EDIT: My sessionInfo():
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] jsonlite_1.6 scales_1.0.0 tidyr_0.8.3 ggplot2_3.2.0 koRpus.lang.de_0.1-1 koRpus_0.11-5
[7] sylly_0.1-5 readxl_1.3.1 data.table_1.12.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 highr_0.8 cellranger_1.1.0 pillar_1.4.1 compiler_3.6.0 tools_3.6.0 zeallot_0.1.0
[8] digest_0.6.19 tibble_2.1.3 gtable_0.3.0 pkgconfig_2.0.2 rlang_0.4.0 cli_1.1.0 rstudioapi_0.10
[15] curl_3.3 yaml_2.2.0 xfun_0.8 knitr_1.23 withr_2.1.2 dplyr_0.8.1 vctrs_0.1.0
[22] grid_3.6.0 tidyselect_0.2.5 sylly.de_0.1-2 glue_1.3.1 R6_2.4.0 fansi_0.4.0 purrr_0.3.2
[29] magrittr_1.5 backports_1.1.4 fortunes_1.5-4 assertthat_0.2.1 colorspace_1.4-1 labeling_0.3 utf8_1.1.4
[36] lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4

RStudio suddenly extremely slow (12 march 2019)

I ran into the super slow problem last Friday, then for 3 days it worked, and now it is back again.
At first I thought it was the internet connection, but that seems not to be the case.
I've already tried various things such as:
- reinstall RStudio
- Reboot PC several times
- Use a different internet network
- remove all .RData and .RHistory files that I could find
but it is still going at crawl speed.
This morning it was running as expected, a few hours later at work, same laptop, it is super slow again.
I have virtually no other programs open, and it is slow straight from the start after a reboot every single time.
Does anyone have any suggestions how to figure out what is causing this, and how to solve it?
I'm running Version 1.1.463 of RStudio on a windows 7 professional.
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] flowPeaks_1.26.0 PerformanceAnalytics_1.5.2 xts_0.11-2 zoo_1.8-4 gtools_3.8.1
[6] lemon_0.4.3 gridExtra_2.3 pryr_0.1.4 scales_1.0.0 stringi_1.3.1
[11] V8_2.0 taRifx_1.0.6.1 webshot_0.5.1 broom_0.5.1 forcats_0.4.0
[16] stringr_1.4.0 dplyr_0.8.0.1 purrr_0.3.1 readr_1.3.1 tibble_2.0.1
[21] tidyverse_1.2.1 randomForest_4.6-14 yaml_2.2.0 plyr_1.8.4 colourpicker_1.0
[26] DT_0.5 tidyr_0.8.3 htmlwidgets_1.3 plotly_4.8.0 ggplot2_3.1.0
[31] bit64_0.9-7 bit_1.1-14 lubridate_1.7.4 shinyWidgets_0.4.5 shinyjqui_0.3.2
[36] shinyjs_1.0 shinydashboard_0.7.1 shinyBS_0.61 data.table_1.12.0 shiny_1.2.0
loaded via a namespace (and not attached):
[1] httr_1.4.0 jsonlite_1.6 viridisLite_0.3.0 modelr_0.1.4 assertthat_0.2.0 cellranger_1.1.0 pillar_1.3.1 backports_1.1.3
[9] lattice_0.20-38 quadprog_1.5-5 glue_1.3.0 digest_0.6.18 promises_1.0.1 rvest_0.3.2 colorspace_1.4-0 htmltools_0.3.6
[17] httpuv_1.4.5.1 pkgconfig_2.0.2 haven_2.1.0 xtable_1.8-3 later_0.8.0 generics_0.0.2 withr_2.1.2 lazyeval_0.2.1
[25] cli_1.0.1 magrittr_1.5 crayon_1.3.4 readxl_1.3.0 mime_0.6 nlme_3.1-137 xml2_1.2.0 tools_3.5.2
[33] hms_0.4.2 munsell_0.5.0 compiler_3.5.2 rlang_0.3.1 rstudioapi_0.9.0 crosstalk_1.0.0 miniUI_0.1.1.1 gtable_0.2.0
[41] codetools_0.2-15 curl_3.3 reshape2_1.4.3 R6_2.4.0 knitr_1.22 Rcpp_1.0.0 xfun_0.5 tidyselect_0.2.5
I was having the same problems in my RStudio Desktop IDE. The main problem was that it was extremely slow to start the IDE and perform trivial tasks like opening a script or using the console to perform basic calculations. Doing some research, this is what helped me:
Resetting RStudio Desktop's State.
Running a Diagnostic Report. My issue was that my HOME environmental variable was set to a network/shared drive (i.e. OneDrive).
I fixed this by setting my HOME env variable to a local directory. Check this solution. Check this thread for more background.
Good luck!

Resources