Lee Jim
Lee Jim

Reputation: 405

sf and rgdal are not working on Mac OS Big Sur, how to fix? --Closed

 library(sf)

Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf/libs/sf.so': dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf/libs/sf.so, 6): Library not loaded: /usr/lib/libpq.5.dylib Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf/libs/sf.so Reason: image not found

 library(rgdal)

Error: package or namespace load failed for ‘rgdal’ in get(method, envir = home): lazy-load database '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/R/rgdal.rdb' is corrupt In addition: Warning messages: 1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4], : restarting interrupted promise evaluation 2: In get(method, envir = home) : restarting interrupted promise evaluation 3: In get(method, envir = home) : internal error -3 in R_decompress1

----Issue closed----

CRAN libraries have been updated to be compatible with Big Sur which removed some system libraries, so just re-install rgdal and sf from CRAN (thanks to Jeroen). To make sure you get the latest versions use

install.packages(c("rgdal","sf"), "https://mac.R-project.org")

ref: https://stat.ethz.ch/pipermail/r-sig-mac/2020-November/013783.html

Upvotes: 3

Views: 2332

Answers (2)

Lee Jim
Lee Jim

Reputation: 405

CRAN libraries have been updated to be compatible with Big Sur which removed some system libraries, so just re-install rgdal and sf from CRAN (thanks to Jeroen). To make sure you get the latest versions use

install.packages(c("rgdal","sf"), "https://mac.R-project.org")

ref: https://stat.ethz.ch/pipermail/r-sig-mac/2020-November/013783.html

Upvotes: 4

MrMobster
MrMobster

Reputation: 1972

The problem is that the R packages rely on the PostgreSQL library that Apple has removed from macOS 11. You can "fix" it for the time being by installing all the required components manually (brew install gdal should do it assuming you use Homebrew) and then re-installing the R packages from source. It's messy, since it will download multiple MBs of unnecessary development packages to your Mac, but it works. I hope that the package maintainers will soon include the missing libraries into the distribution of sf and rgdal directly.

Upvotes: 5

Related Questions