Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install macOS Monterey v12.3.1 fails on missing gdal-config #1949

Closed
qwertytam opened this issue May 30, 2022 · 5 comments
Closed

Install macOS Monterey v12.3.1 fails on missing gdal-config #1949

qwertytam opened this issue May 30, 2022 · 5 comments

Comments

@qwertytam
Copy link

qwertytam commented May 30, 2022

Describe the bug
Install macOS Monterey v12.3.1 fails on missing gdal-config

To Reproduce
Trying to install sf on macOS Monterey v12.3.1 aarch64-apple-darwin21.3.0 with R version 4.2.0 using homebrew

Additional context
Have tried the following to resolve:

Each time I keep getting

checking for geos-config... no
no
configure: error: geos-config not found or not executable.

$ locate gdal-config gives

/opt/homebrew/Cellar/gdal/3.5.0/bin/gdal-config
/opt/homebrew/Cellar/gdal/3.5.0/share/man/man1/gdal-config.1
/opt/homebrew/bin/gdal-config
/opt/homebrew/share/man/man1/gdal-config.1

$ which gdal-config gives

/opt/homebrew/bin/gdal-config

$ gdal-config --version gives

3.5.0

So it looks like gdal is install correctly?

$ proj gives

Rel. 9.0.0, March 1st, 2022

So it looks like proj is install correctly?

Have done multiple restarts of R session.

Have this in .Reniron in my project folder

LIBRARY_PATH=/opt/homebrew/bin/

With the install then terminating unsuccessfully. Full console prints below. Any and all help appreciated!

`sessionInfo()`
R version 4.2.0 (2022-04-22)
Platform: aarch64-apple-darwin21.3.0 (64-bit)
Running under: macOS Monterey 12.3.1

Matrix products: default
LAPACK: /opt/homebrew/Cellar/r/4.2.0/lib/R/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.0 tools_4.2.0   

Trying to install rgeos

> install.packages("rgeos", repos="http://R-Forge.R-project.org", type="source")
Installing package into ‘/Users/tam/Library/R/arm64/4.2/library’
(as ‘lib’ is unspecified)
trying URL 'http://R-Forge.R-project.org/src/contrib/rgeos_0.5-10.tar.gz'
Content type 'application/x-gzip' length 280616 bytes (274 KB)
==================================================
downloaded 274 KB

* installing *source* package ‘rgeos’ ...
** using staged installation
configure: CC: clang
configure: CXX: clang++ -std=gnu++14
configure: rgeos: 0.5-10
checking for /usr/bin/svnversion... no
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision: 
checking for geos-config... no
no
configure: error: geos-config not found or not executable.
ERROR: configuration failed for package ‘rgeos’
* removing ‘/Users/tam/Library/R/arm64/4.2/library/rgeos’
Warning in install.packages :
  installation of package ‘rgeos’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/4w/1gfqjwcd60sdlg02q277ll200000gn/T/RtmpCPAm07/downloaded_packages’

Trying to install rgdal gives

> install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source")
Installing package into ‘/Users/tam/Library/R/arm64/4.2/library’
(as ‘lib’ is unspecified)
trying URL 'http://R-Forge.R-project.org/src/contrib/rgdal_1.5-32.tar.gz'
Content type 'application/x-gzip' length 4341872 bytes (4.1 MB)
==================================================
downloaded 4.1 MB

* installing *source* package ‘rgdal’ ...
** using staged installation
configure: R_HOME: /opt/homebrew/Cellar/r/4.2.0/lib/R
configure: CC: clang
configure: CXX: clang++ -std=gnu++14
configure: CFLAGS: -Wno-implicit-function-declaration
configure: CPPFLAGS: -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include
configure: CXXFLAGS: -g -O2
configure: LDFLAGS: -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib
configure: LDFLAGS: -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib
configure: CXX11 is: clang++, CXX11STD is: -std=gnu++11
configure: CXX is: clang++ -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.5-32
checking for /usr/bin/svnversion... no
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision: 
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Users/tam/Library/R/arm64/4.2/library/rgdal’
Warning in install.packages :
  installation of package ‘rgdal’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/4w/1gfqjwcd60sdlg02q277ll200000gn/T/RtmpCPAm07/downloaded_packages’
@qwertytam
Copy link
Author

qwertytam commented May 30, 2022

Update, installing rgdal with by specifying brew install locations explicitly gives configure: error: API to be used not found

Changed FLAGS to brew locations as well. Restarted R session after exporting FLAGS and before trying rgdal install.

$ export LDFLAGS="-L/opt/homebrew/Cellar/libpq/14.3/lib"
$ export CPPFLAGS="-I/opt/homebrew/Cellar/libpq/14.3/include"

Full console dump:

Restarting R session...

> install.packages("rgdal", repos="http://R-Forge.R-project.org", type="source", configure.args=c("--with-proj-include=/opt/homebrew/Cellar/proj/9.0.0_1/bin", "--with-proj-lib=/opt/homebrew/Cellar/proj/9.0.0_1/lib", "--with-gdal-config=/opt/homebrew/Cellar/gdal/3.5.0/bin/gdal-config"))
Installing package into ‘/Users/tam/Library/R/arm64/4.2/library’
(as ‘lib’ is unspecified)
trying URL 'http://R-Forge.R-project.org/src/contrib/rgdal_1.5-32.tar.gz'
Content type 'application/x-gzip' length 4341872 bytes (4.1 MB)
==================================================
downloaded 4.1 MB

* installing *source* package ‘rgdal’ ...
** using staged installation
configure: R_HOME: /opt/homebrew/Cellar/r/4.2.0/lib/R
configure: CC: clang
configure: CXX: clang++ -std=gnu++14
configure: CFLAGS: -Wno-implicit-function-declaration
configure: CPPFLAGS: -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include
configure: CXXFLAGS: -g -O2
configure: LDFLAGS: -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib
configure: LDFLAGS: -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib
configure: CXX11 is: clang++, CXX11STD is: -std=gnu++11
configure: CXX is: clang++ -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.5-32
checking for /usr/bin/svnversion... no
cat: inst/SVN_VERSION: No such file or directory
configure: svn revision: 
configure: gdal-config set to /opt/homebrew/Cellar/gdal/3.5.0/bin/gdal-config
checking gdal-config exists... yes
checking gdal-config executable... yes
checking gdal-config usability... yes
configure: GDAL: 3.5.0
checking GDAL version >= 1.11.4... yes
checking GDAL version <= 2.5 or >= 3.0... yes
checking GDAL: linking with --libs only... yes
checking GDAL: gdal-config data directory readable... yes
checking GDAL: /opt/homebrew/Cellar/gdal/3.5.0/share/gdal/stateplane.csv readable... yes
./configure: line 2521: pkg-config: command not found
configure: pkg-config proj not available
  set PKG_CONFIG_PATH to the directory containing proj.pc
configure: PROJ version not determined using pkg-config proj
configure: PROJ CPP flags:  -I/opt/homebrew/Cellar/gdal/3.5.0/include -I/opt/homebrew/Cellar/proj/9.0.0_1/bin 
configure: PROJ LIBS: -L/opt/homebrew/Cellar/proj/9.0.0_1/lib 
checking PROJ header API:... yes
configure: API to be used as yet undetermined, searching ...
configure: error: API to be used not found
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Users/tam/Library/R/arm64/4.2/library/rgdal’
Warning in install.packages :
  installation of package ‘rgdal’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/4w/1gfqjwcd60sdlg02q277ll200000gn/T/Rtmp9E6uBt/downloaded_packages’
> 

@rsbivand
Copy link
Member

If the "Installing packages linking to PROJ, GDAL or GEOS" section in https://cran.r-project.org/view=Spatial is unclear, please raise an issue there. Unless you definitely know that your homebrew binary GDAL 3.5.0 provides functionality not present in the relatively fresh GDAL binaries used for CRAN binary builds, please install binary only. Nobody is available to support source installs using homebrew. The advice on https://github.com/r-spatial/sf/#installing is stale and misleading.

@qwertytam If proj.pc is not used, an attempt will be made to try to guess whether a unique proj.h or proj_api.h can be found (see the error message: configure: pkg-config proj not available). My guess would be that setting up pkg-config and its environment variables would help. Anyway, better to try a dry run by untarring the source tarball and dry-running ./configure until it succeeds than failing a full download/installation.

@qwertytam
Copy link
Author

So after many more rabbit holes, removed the R and RStudio installed via homebrew and went with a fresh R install (using binary from CRAN website) and RStudio install, and looks like no more problem.

@laurivaltteri
Copy link

Holes with rabbits. Finally got it installed on Monterey (M1). renv cannot unfortunately be used. But this spell worked after installing all the necessary libraries with brew

install.packages("sf", type = "source", configure.args = 
'--with-gdal-lib=/opt/homebrew/opt/gdal/lib/ 
--with-sqlite3-lib=/opt/homebrew/opt/sqlite/lib/ 
--with-gdal-config=/opt/homebrew/bin/gdal-config
--with-proj-share=/opt/homebrew/opt/proj/share/ 
--with-proj-lib=/opt/homebrew/opt/proj/lib 
--with-proj-include=/opt/homebrew/opt/proj/include/
--with-geos-config=/opt/homebrew/opt/geos/bin/geos-config')

@daauerbach
Copy link

much obliged for your sharing @laurivaltteri!! this worked for me on Ventura M1 (after a session restart to clear the 'corrupt' lazy load db)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants