Upgrading to Mac OS 11 - Big Sur appears to have created an issue in installing and loading 'sf'. The issue seems specific to the 'rgdal' package, which is looking for the library "libpq.5.dylib" which no longer exists in "/usr/lib/". Found another post on the same problem here: https://github.com/R-macos/recipes/issues/14, though no solutions yet. Anyone have thoughts on how to resolve this?
Error reported in R when install sf and/or rgdal:
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
https://twitter.com/opencpu/status/1326902988334657537?s=19
A known issue, and good advice not to upgrade until those who understand
Apple (I do not) confirm that it is safe to do so. Following R-sig-mac is
also advised https://stat.ethz.ch/mailman/listinfo/r-sig-mac.
Roger Bivand
Falsensvei 32
5063 Bergen
fre. 13. nov. 2020, 20:24 skrev codyevers notifications@github.com:
Upgrading to Mac OS 11 - Big Sur appears to have created an issue in
installing and loading 'sf'. The issue seems specific to the 'rgdal'
package, which is looking for the library "libpq.5.dylib" which no longer
exists in "/usr/lib/". Found another post on the same problem here:
R-macos/recipes#14 https://github.com/R-macos/recipes/issues/14, though
no solutions yet. Anyone have thoughts on how to resolve this?Error reported in R when install sf and/or rgdal:
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—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/r-spatial/sf/issues/1536, or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACNZ3BABGYG3AIHBKOF2M6LSPWBWTANCNFSM4TU62MQQ
.
These steps worked for me ...
PART 1: Using Terminal
1) Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2) Install the packages:
brew install pkg-config
brew install gdal proj geos
2.1) Not sure it's necessary ... I included it on terminal.
export LDFLAGS="-L/usr/local/opt/libpq/lib"
export CPPFLAGS="-I/usr/local/opt/libpq/include"
PART 2: Using R
install.packages("rgeos", repos="http://R-Forge.R-project.org", type="source")
install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")
library(devtools)
install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")
Restart R and tidycensus, rgdal, rgeos, and sf will load properly.
Fantastic @abuabara. I can confirm that this fixed the problem on my end, and I assume will work for anyone else running into this issue after installing Mac OS 11 - Big Sur. Thanks for the quick fix!
Hi there. I get this when running the last line of code:
> install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")
Downloading GitHub repo r-spatial/sf@HEAD
Error: Failed to install 'sf' from GitHub:
Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
Warning message:
1 components of `...` were not used.
We detected these problematic arguments:
* `configure.args`
Did you misspecify an argument?
I then tried this, but without success:
> options(buildtools.check = function(action) TRUE )
> install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")
Downloading GitHub repo r-spatial/sf@HEAD
✓ checking for file ‘/private/var/folders/np/x2bs8n2s6d996fkt00vssqnw0000gn/T/RtmpABGiuf/remotes10853f3de773/r-spatial-sf-af12048/DESCRIPTION’ ...
─ preparing ‘sf’:
✓ checking DESCRIPTION meta-information ...
─ cleaning src
─ running ‘cleanup’
─ checking for LF line-endings in source and make files and shell scripts (454ms)
─ checking for empty or unneeded directories
─ building ‘sf_0.9-7.tar.gz’
* installing *source* package ‘sf’ ...
** using staged installation
configure: CC: /usr/local/clang4/bin/clang
configure: CXX: /usr/local/clang4/bin/clang++ -std=gnu++11
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.2.0
checking GDAL version >= 2.0.1... yes
checking for gcc... /usr/local/clang4/bin/clang
checking whether the C compiler works... no
configure: error: in `/private/var/folders/np/x2bs8n2s6d996fkt00vssqnw0000gn/T/RtmpJKE5hT/R.INSTALL10d0ad0d386/sf':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf’
Error: Failed to install 'sf' from GitHub:
(converted from warning) installation of package ‘/var/folders/np/x2bs8n2s6d996fkt00vssqnw0000gn/T//RtmpABGiuf/file108579264f74/sf_0.9-7.tar.gz’ had non-zero exit status
This is my _brew less_ version... to fix the install of sf on macOS 11.0.1 (Big Sur)
Note: change _-j56_ below in the code to the number of CPU on your machine
macOS terminal
cd ~/Downloads
curl -L https://www.unidata.ucar.edu/downloads/udunits/udunits-2.2.26.tar.gz | tar xf -
cd udunits*
./configure && make -j56 && sudo make install
cd ..
sudo rm -R udunits*
cd ~/Downloads
curl -L https://www.sqlite.org/2020/sqlite-autoconf-3330000.tar.gz | tar xf -
cd sqlite-autoconf*
./configure && make -j56 && sudo make install
cd ..
sudo rm -R sqlite-autoconf*
cd ~/Downloads
curl -L https://download.osgeo.org/libtiff/tiff-4.1.0.tar.gz | tar xf -
cd tiff*
./configure && make -j56 && sudo make install
cd ..
sudo rm -R tiff*
cd ~/Downloads
curl -L http://download.osgeo.org/proj/proj-7.2.0.tar.gz | tar xf -
cd proj*
./configure --libdir=/usr/local/lib && make -j56 && sudo make install
cd ..
sudo rm -R proj*
export LDFLAGS="-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/include"
cd ~/Downloads
curl -L https://github.com/OSGeo/gdal/releases/download/v3.2.0/gdal-3.2.0.tar.gz | tar xf -
cd gdal*
./configure --prefix=/usr/local --libdir=/usr/local/lib --with-proj=/usr/local && make -j56 && sudo make install
cd ..
sudo rm -R gdal*
cd ~/Downloads
git clone https://git.osgeo.org/gitea/geos/geos.git
cd geos*
./autogen.sh
./configure --libdir=/usr/local/lib && make -j56 && sudo make install
cd ..
sudo rm -R geos*
Back in R console
install.packages("rgeos", repos="http://R-Forge.R-project.org", type="source")
install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")
devtools::install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local")
@thierrygosselin you should be really careful using sudo make install because there is no way to uninstall those libs, they will linger on the system forever and may start conflicting with other things. Also if you build gdal like this, you are missing all of the drivers that are provided by 3rd party dependency libraries.
If you're going to install GDAL manually, I much recommend using brew or another package manager, so that you can upgrade or uninstall the gdal files when you don't need them anymore.
@jeroen not sure for GDAL, I'm barely using it, I need sf to run adegenet, and for 99% of the other genomics related packages and software I use, I see only advantages of using sudo make install:
/usr/local/ is in the PATH by defaults, that's a plus for novice usersBest,
Thierry
Thanks @abuabara - ran with a slight simplification. These steps worked for me ...
PART 1: Using Terminal
Using Homebrew, install gdal:
brew install pkg-config
brew install gdal proj geos
(Homebrew installs gdal, proj, and geos into a Cellar, and then symlinks these into the /usr/local/lib folder. You can ignore the postgres formula "keg only" warning produced when libpq is installed.)
PART 2: Using R
devtools::install_github("r-spatial/sf", configure.args="--with-proj-lib=/usr/local/lib/")
Thanks @abuabara - ran with a slight simplification. These steps worked for me ...
PART 1: Using Terminal
Using Homebrew, install gdal:
brew install pkg-config brew install gdal proj geos(Homebrew installs gdal, proj, and geos into a Cellar, and then symlinks these into the /usr/local/lib folder. You can ignore the postgres formula "keg only" warning produced when libpq is installed.)
PART 2: Using R
devtools::install_github("r-spatial/sf", configure.args = "--with-proj-lib=/usr/local/lib/")Restart R and sf will load properly.
In my case no need for restarting R.
This problem is now fixed on CRAN. You can now install the sf and rgdal packages from CRAN in the regular way on MacOS big sur.
Most helpful comment
These steps worked for me ...
PART 1: Using Terminal
1) Install brew
2) Install the packages:
2.1) Not sure it's necessary ... I included it on terminal.
PART 2: Using R
Restart R and tidycensus, rgdal, rgeos, and sf will load properly.