Jouline
Jouline

Reputation: 90

gdal-config not found while installing packages, Mac M1 Ventura

I am trying to install some packages to work with spatial data such as sf, stars, rgdal, on a Mac Book Air M1 with Ventura.
To do so, I need to have gdal installed to my compute, which I have. My problem is that when I try to install a library (see example with sf here below), the gdal-config file is not found.

Example with sf installation

But I have it on my computer, so my question is :
Is there a way to indicate the path to R to find that file ?

I tried to to uninstall and reinstall gdal with homebrew, I have proj that is also a dependency rightly installed. I need to install from sf from sources as it is needed to install the stars package.

(base)@MacBook-Air ~ % echo $PATH
/opt/homebrew/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
(base)@MacBook-Air ~ % whereis gdal-config
gdal-config: /opt/homebrew/bin/gdal-config /opt/homebrew/share/man/man1/gdal-config.1
(base)@MacBook-Air ~ % gdal-config
Usage: gdal-config [OPTIONS]
Options:
    [--prefix[=DIR]]
    [--libs]
    [--dep-libs]
    [--cflags]
    [--datadir]
    [--version]
    [--ogr-enabled]
    [--gnm-enabled]
    [--formats]
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS  13.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/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.0.3 tools_4.0.3
(base)@MacBook-Air ~ % proj
DeprecationWarning: PROJ_LIB environment variable is deprecated, and will be removed in a future release. You are encouraged to set PROJ_DATA instead.
Rel. 9.1.1, December 1st, 2022
usage: proj [-bdeEfiIlmorsStTvVwW [args]] [+opt[=arg] ...] [file ...]

P.S: I know there are a lots of related topics (Error: gdal-config not found while installing R dependent packages whereas gdal is installed), but all of them are on Linux, and the solutions are not working for me on Mac machine.

Upvotes: 0

Views: 361

Answers (1)

Jouline
Jouline

Reputation: 90

I solved it by reinstalling the latest version of R and R Studio.

Upvotes: 0

Related Questions