After updating RStudio to 4.2.2 I got a peculiar problem

Running the packages needed for my script gives the following messages (some packages I can install other gives an error and I can't figure out what has happened (Session info below):
library("ggrepel")

library(glue)
remove.packages("tidyverse")
Removing package from ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library’
(as ‘lib’ is unspecified)
library(tidyverse)
Error in library(tidyverse) : there is no package called ‘tidyverse’
library(tidyr)
Error: package or namespace load failed for ‘tidyr’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr/libs/dplyr.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr/libs/dplyr.so, 0x0006): Library not loaded: '/Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libR.dylib'
Referenced from: '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr/libs/dplyr.so'
Reason: tried: '/Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libR.dylib' (no such file), '/usr/local/lib/libR.dylib' (no such file), '/usr/lib/libR.dylib' (no such file)
detach("package:tidyr", unload = TRUE)
Error in detach("package:tidyr", unload = TRUE) : invalid 'name' argument
install.packages("tidyverse")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.2/tidyverse_1.3.2.tgz'
Content type 'application/x-gzip' length 420896 bytes (411 KB)
==================================================
downloaded 411 KB

The downloaded binary packages are in
/var/folders/mm/c9c1scj14y9gpcvdm1kv8dhc0000gn/T//Rtmp4DblEF/downloaded_packages

library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr/libs/dplyr.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr/libs/dplyr.so, 0x0006): Library not loaded: '/Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libR.dylib'
Referenced from: '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/dplyr/libs/dplyr.so'
Reason: tried: '/Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libR.dylib' (no such file), '/usr/local/lib/libR.dylib' (no such file), '/usr/lib/libR.dylib' (no such file)

Session info:
sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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

other attached packages:
[1] glue_1.6.2 ggrepel_0.9.2 ggpp_0.5.0 gginnards_0.1.1
[5] reshape_0.8.9 RColorBrewer_1.1-3 patchwork_1.1.2 ggplotify_0.1.0
[9] ggplot2_3.4.0 FME_1.3.6.2 coda_0.19-4 rootSolve_1.8.2.3
[13] deSolve_1.34

loaded via a namespace (and not attached):
[1] minpack.lm_1.2-2 tidyselect_1.2.0 lattice_0.20-45 colorspace_2.0-3
[5] vctrs_0.5.1 generics_0.1.3 utf8_1.2.2 gridGraphics_0.5-1
[9] rlang_1.0.6 pillar_1.8.1 withr_2.5.0 lifecycle_1.0.3
[13] plyr_1.8.8 munsell_0.5.0 gtable_0.3.1 evaluate_0.19
[17] fansi_1.0.3 Rcpp_1.0.9 scales_1.2.1 digest_0.6.31
[21] grid_4.2.2 cli_3.5.0 tools_4.2.2 yulab.utils_0.0.6
[25] magrittr_2.0.3 tibble_3.1.8 pkgconfig_2.0.3 Matrix_1.5-1
[29] MASS_7.3-58.1 minqa_1.2.5 rstudioapi_0.14 R6_2.5.1
[33] compiler_4.2.2

What do you get from the console with

.libPaths()

Note the odd initial period. And is it different in the R GUI or terminal?

Both RStudio and R give:
.libPaths()
[1] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library"
Terminal :slight_smile: (base) MBPtilhdeHenrik:PiloKubota XXXXXXX$
Changed directory but still experience the errors

Looking through the files it seems that "lib" is missing? /4.1/Resources/lib/libR.dylib'

Here is what you should have if R has been installed from CRAN with the defaults:

 pwd
/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib

4.2-arm64/Resources/lib🔒 
❯ tree  
.
├── libR.dylib
├── libR.dylib.dSYM
│   └── Contents
│       ├── Info.plist
│       └── Resources
│           └── DWARF
│               └── libR.dylib
├── libRblas.0.dylib
├── libRblas.0.dylib.dSYM
│   └── Contents
│       ├── Info.plist
│       └── Resources
│           └── DWARF
│               └── libRblas.0.dylib
├── libRblas.dylib -> libRblas.0.dylib
├── libRblas.dylib.dSYM
│   └── Contents
│       ├── Info.plist
│       └── Resources
│           └── DWARF
│               └── libRblas.dylib
├── libRblas.vecLib.dylib
├── libRblas.vecLib.dylib.dSYM
│   └── Contents
│       ├── Info.plist
│       └── Resources
│           └── DWARF
│               └── libRblas.vecLib.dylib
├── libRlapack.dylib
├── libRlapack.dylib.dSYM
│   └── Contents
│       ├── Info.plist
│       └── Resources
│           └── DWARF
│               └── libRlapack.dylib
├── libgcc_s.1.1.dylib
├── libgfortran.5.dylib
└── libquadmath.0.dylib

These are needed to hook packages into the R eco-system. Correspondingly, R default for Mac is

❯ l /usr/local/bin/R
lrwxr-xr-x 47 root 30 Nov 22:17 /usr/local/bin/R -> /Library/Frameworks/R.framework/Resources/bin/R

Check in the terminal to confirm you are similar?

Yes finally I found out how to document it - all the files and the referral is in place

temporary solution: installed RStudio 2022.07.2 Build 576 and it solved the problems. It would be nice to have a future-proofed solution

1 Like

Find the solution here: https://community.rstudio.com/t/rstudio-2022-12-0-353-on-mac-monterey-library-problems/157061/4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.