sf won't install for anyone on Posit cloud

Hello!

The sf package no longer installs on posit cloud. Trying to install via install_github("r-spatial/sf") gives a similar error. Full error below.

I'm guessing it's linked to the changes with GDAL/PROJ and needs fixing on the back end? Other spatial packages are working fine. Is there are any posit ppl reading this, any chance this is a quick fix?
I'm hoping someone will notice something stupid I'm missing.

(I'm teaching spatial statistics to 60 undergrads this semester, so this is a REALLY deal for me. Without complaining too much, I've point where I'm about to ditch Posit and move the entire class to an AWS Geospatial Docker. Which would make me sad! The recent big PROJ map projection changes means it's not an option to install/use an old version of sf without breaking my labs)

The error and a few things I tried.

> install.packages("sf")
Installing package into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.4’
(as ‘lib’ is unspecified)
trying URL 'http://rspm/default/__linux__/focal/latest/src/contrib/sf_1.0-17.tar.gz'
Content type 'application/x-gzip' length 3863868 bytes (3.7 MB)
==================================================
downloaded 3.7 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc
configure: CXX: g++ -std=gnu++17
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.0.4
checking GDAL version >= 2.0.1... yes
checking for gcc... gcc
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 the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available for running:... yes
configure: GDAL: 3.0.4
configure: pkg-config proj exists, will use it
configure: using proj.h.
configure: PROJ: 6.3.1
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... yes
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.8.0
checking GEOS version >= 3.4.0... yes
checking for geos_c.h... yes
checking geos: linking with -L/usr/lib/x86_64-linux-gnu -lgeos_c... yes
configure: Package CPP flags:   -DHAVE_PROJ_H -I/usr/include/gdal -I/usr/include
configure: Package LIBS: -lproj   -L/usr/lib -lgdal -L/usr/lib/x86_64-linux-gnu -lgeos_c
configure: creating ./config.status
config.status: creating src/Makevars
** libs
using C++ compiler: ‘g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0’
g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/usr/include/gdal -I/usr/include -I'/cloud/lib/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I/usr/local/include    -fpic  -g -O2   -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/usr/include/gdal -I/usr/include -I'/cloud/lib/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I/usr/local/include    -fpic  -g -O2   -c bbox.cpp -o bbox.o
g++ -std=gnu++17 -I"/opt/R/4.4.1/lib/R/include" -DNDEBUG -DHAVE_PROJ_H -I/usr/include/gdal -I/usr/include -I'/cloud/lib/x86_64-pc-linux-gnu-library/4.4/Rcpp/include' -I/usr/local/include    -fpic  -g -O2   -c gdal.cpp -o gdal.o
gdal.cpp: In function ‘Rcpp::NumericVector CPL_transform_bounds(Rcpp::NumericVector, Rcpp::List, int)’:
gdal.cpp:713:9: error: ‘ret’ was not declared in this scope
  713 |  return ret;
      |         ^~~
make: *** [/opt/R/4.4.1/lib/R/etc/Makeconf:204: gdal.o] Error 1
ERROR: compilation failed for package ‘sf’
* removing ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.4/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

It's also reporting that GDAL and Proj are well out of date - which I think is the underlying issue.

> system("gdal-config --version")
3.0.4

We're currently on version 3.9.2 - Download — GDAL documentation and there was a huge update in the last year. sf works on my computer which is running 3.3.2.

More importantly, I think posit cloud is running PROJ v 6.3.1 rather than the big update to v 7. (I have 7.1.0 on my computer where sf works.)

> system("proj")
Rel. 6.3.1, February 10th, 2020
usage: proj [-bdeEfiIlmorsStTvVwW [args]] [+opt[=arg] ...] [file ...]

Thanks!
Helen

Hi @wispa84!

That's a rough experience and I was able to repro this. We obtain the version of gdal from the ubuntu apt repo for our current ubuntu version (20.04, focal) which is still at 3.0.4.

It does look like this was actually a bug introduced in the latest version of sf -- with a fix on the way: sf 1.0-17 fails to install with GDAL < 3.4: gdal.cpp:713:16: error: ‘ret’ was not declared in this scope · Issue #2436 · r-spatial/sf · GitHub

1 Like

If you'd like, you can actually install/compile from that branch of the project in github. Since the package has to compile, the experience is a bit slow -- but hopefully is a sufficent workaround until the bug is fixed!

remotes::install_github(repo = "r-spatial/sf", ref = "93a25fd8e2f5c6af7c080f92141cb2b765a04a84")

Oh you are a SUPERSTAR, thank you. I'll check it out now - and I love this community :slight_smile: Thanks also for the detective work on the sf side. I genuinely thought I had gone through all the sf issues on their end.

(If sf folks are reading this, I also know how insanely hard you are working on this "volunteer open source" language. It's revolutionised what I (and my students) can do with data - not least because we rarely have to worry about things like PROJ updates - so thanks also!)

Helen.

1 Like

I'm so glad it helped! it looks like they've merged the fix (so remotes::install_github(repo = "r-spatial/sf") should work now) , but I believe it will take a few days to make it to CRAN, and then into the posit.cloud package manager!

Same problem. The suggested
remotes::install_github(repo = "r-spatial/sf")

in the console on Posit.cloud stalls at:
─ preparing ‘sf’: ✔ checking DESCRIPTION meta-information ─ cleaning src ─ running ‘cleanup’ ─ installing the package to process help pages

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.