r-spatial / sf

Simple Features for R
https://r-spatial.github.io/sf/
Other
1.33k stars 294 forks source link

Error loading the package in Mac OS 10.16 #1502

Closed Dekermanjian closed 3 years ago

Dekermanjian commented 3 years ago

The package was working well before I updated my Mac OS to the beta version of Big Sur. Now the package doesn't load. I am wondering if this is an OS incompatibility or if the update broke something. Through reading other Issue posts on the GitHub repo I tried brew install gdal and brew install jasper, neither worked. Below is an image of the error and the session info. Any help is greatly appreciated.

Screen Shot 2020-10-02 at 8 29 30 AM
Nowosad commented 3 years ago

Have you tried to reinstall sf?

install.packages("sf")
Dekermanjian commented 3 years ago

Hello. Yes, I have tried re-installing sf. I also tried removing it first, remove.packages("sf"), then re-installing it. Neither case worked.

edzer commented 3 years ago

Did you do a source install or a binary install?

Dekermanjian commented 3 years ago

I followed the instructions on the GitHub page and did a source install usinginstall.packages("sf", configure.args = "--with-proj-lib=/usr/local/lib/")

edzer commented 3 years ago

Please try install.packages("sf", type = "mac.binary")

Dekermanjian commented 3 years ago

It still returns the same error.

Screen Shot 2020-10-02 at 10 14 38 AM
Dekermanjian commented 3 years ago

Here are gdal and pkg-config versions. If that helps at all.

Screen Shot 2020-10-02 at 10 20 26 AM
edzer commented 3 years ago

Maybe your update was the problem?

Dekermanjian commented 3 years ago

Yes, that is likely the cause of the problem. Now the question is will all users who update to MacOS Big Sur at the end of the month experience the same problem or is this issue specific to my machine?

cris-silva commented 3 years ago

This issue indeed happened to me today when upgraded to Big Sur. After researching, finally I found a solution here:

https://stackoverflow.com/questions/64256675/copy-libpq-5-dylib-to-usr-lib-libpq-5-dylib

Looks like macOS is keeping libraries on /usr/lib closed. Basically is needed to point back /usr/lib/libpq.5.dylib against another libpq, like the one you get by installing it with Homebrew.

This is what worked for me, first uninstall sf and rgdal packages in R and use HomeBrew to install libpq if needed:

$ brew install libpq

Check if library is pointing itself:

$ otool -l /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib | fgrep -A2 LC_ID_DYLIB

If not, point it against itself:

$ sudo install_name_tool -id /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib

And link the new path of libpq to each R package binary that references to it:

$ sudo install_name_tool -change /usr/lib/libpq.5.dylib [new_path] [path_to_binary]

In this case, for sf and rgdal:

$ sudo install_name_tool -change /usr/lib/libpq.5.dylib /usr/local/Cellar/libpq/13.1/lib/libpq.5.dylib /Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf/libs/sf.so

$ sudo install_name_tool -change /usr/lib/libpq.5.dylib /usr/local/Cellar/libpq/13.1/lib/libpq.5.dylib /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so
jeroen commented 3 years ago

This problem is now fixed on CRAN. You can install the packages from CRAN in the regular way.

omerseze commented 10 months ago

the problem still persists when I try to install the RWeka package in R studio, R studio closes itself, the application crashes directly, what is my problem, although I have installed compatible java to the apple m1 processor, I encounter the same problem

rsbivand commented 10 months ago

@omerseze Please read recent threads on R-sig-mac https://stat.ethz.ch/mailman/listinfo/r-sig-mac, look in the archives, subscribe if you wish to ask there. This issue is closed and probably irrelevant for your problem.