I'm trying to install sf 0.9-0 on my Mac (running macOS Catalina 10.15.4) and I haven't been able to due to a configuration error. Seems like I'm missing a file (?) called libproj...
After running `install.package("sf") I get a prompt asking if I want to install the package from source, I said yes and I got the following output:
installing the source package ‘sf’
trying URL 'https://cran.rstudio.com/src/contrib/sf_0.9-0.tar.gz'
Content type 'application/x-gzip' length 8474738 bytes (8.1 MB)
==================================================
downloaded 8.1 MB
* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: clang
configure: CXX: clang++ -std=gnu++11
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.4.4
checking GDAL version >= 2.0.1... yes
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/local/Cellar/gdal/2.4.4_2/share/gdal/pcs.csv readable... yes
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 2.4.4
checking proj.h usability... yes
checking proj.h presence... yes
checking for proj.h... yes
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... no
configure: error: libproj not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf’
I also tried installing it using devtools::install_github("r-spatial/sf") without success. I think the outputs are the same but here it is in case I overlooked something:
Downloading GitHub repo r-spatial/sf@master
✓ checking for file ‘/private/var/folders/qp/11_9l8590y79g2ck741t5dx00000gq/T/RtmpfhBVcC/remotes15c2199afdc7/r-spatial-sf-8cc2adf/DESCRIPTION’ (367ms)
─ preparing ‘sf’:
✓ checking DESCRIPTION meta-information ...
─ cleaning src
─ running ‘cleanup’
─ checking for LF line-endings in source and make files and shell scripts (498ms)
─ checking for empty or unneeded directories
─ building ‘sf_0.9-1.tar.gz’
* installing *source* package ‘sf’ ...
** using staged installation
configure: CC: clang
configure: CXX: clang++ -std=gnu++11
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.4.4
checking GDAL version >= 2.0.1... yes
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/local/Cellar/gdal/2.4.4_2/share/gdal/pcs.csv readable... yes
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: GDAL: 2.4.4
checking proj.h usability... yes
checking proj.h presence... yes
checking for proj.h... yes
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... no
configure: error: libproj not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf’
Error: Failed to install 'sf' from GitHub:
(converted from warning) installation of package ‘/var/folders/qp/11_9l8590y79g2ck741t5dx00000gq/T//RtmpfhBVcC/file15c2502038fa/sf_0.9-1.tar.gz’ had non-zero exit status
This happens even after following the instructions from sf's GitHub repo (e.g., install pkg-config and gdal through homebrew), which should make it possible to install sf from source so I have no idea where I went wrong...
The error means you do not have the PROJ.4 library installed; it is the backend that handles various projection tasks (as you no doubt have guessed). {sf} requires three such backends - GDAL, PROJ and GEOS - to function correctly.
I am not a Mac user, but according to the documentation it might be handled by
The short answer is that things went south when accepting the offer to install from source. Sometimes things go smoothly, and often you get the dreaded non-zero exit status or, configuration failed.
This is due to Apple's non-standard compiler. St. Simon Urbanek of the R Core Development Team relieves MAC users like us of the brain damage required to edit the source code to allow it to compile on our machines and provides binary versions. Normally, this takes 7-10 days after a new CRAN version appears. devtools versions don't get that love, however.
I'm happily using sf_0.8-1 in binary, and it happily chirps Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0.
I'll give the reprex section a read, thanks for sharing it
Your reply was super interesting to read! Considering what you said, that sf 0.8-1 works in my computer, and the fact I'm not in dire need of using version 0.9-0, waiting for the binary version seems like the way to go
Should you feel the irrational need to live on the bleeding edge (and from what I am told PROJ.4 version 6.0.0 and higher are not for the faint of heart) you may have to specify the paths to GEOS, GDAL and PROJ manually via --configure-args.
Thanks for the link @jlacko! I'll try to resist the temptation of trying it out myself though xD
I'm currently in a weird place when it comes to knowing how to use my computer. I know a little bit, so sometimes I can install software that takes more than a package.install() (or brew install for that matter) but I rarely know what I'm really doing. It seems like the discussion you shared might be one of those cases: I might be able to follow the instructions but I don't understand most of what they are saying there. From my previous experiences, this is the sort of situation that might lead to me breaking something that I can't fix, so I'll avoid the bleeding edge for now xD
I really appreciate the link anyway, thanks again for sharing it
I'm a newbie in spatial analyses/packages so I was defaulting to trying to get the most recent package versions I could. I'm happy to hear that not being 100% up-to-date won't be such a hassle
Thanks for the contribution. We who are on macOS pay a price to hang on to all the polished conveniences and consistent conventions. This is a great example.
I must say, I very rarely run into troubles with macOS and it provided me a tremendous boost of productivity compared to the very same work I did for years on Windows and Linux. It's worth every penny
Decline the "compile from source" option and install the most recent binary version, which works just fine. Or
Wait for the latest and greatest sf version to become available in binary before trying it out.
When I have a need to be on a later version than is currently avail in macOS in binary, I install it on one of my Linux machines. Also, consider that the very latest features for a package that a user hasn't yet become familiar with the basics of are unlikely to be needed.
This is what happens if you just say no:
There is a binary version available but the source version is later:
binary source needs_compilation
sf 0.8-1 0.9-0 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) n
trying URL 'http://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/sf_0.8-1.tgz'
Content type 'application/x-gzip' length 64283240 bytes (61.3 MB)
==================================================
downloaded 61.3 MB
library(sf)
Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0