Problems installing rgdal macOS Monterey

I'm having problems installing rgdal. I don't know if the issue has to do with the laptop being a MacBook m1. When I try to install it I get these errors and warnings:

ERROR: configuration failed for package ‘rgdal’

  • removing ‘/Users/angiegonzalezrosario/Library/R/x86_64/4.1/library/rgdal’
    Warning in install.packages :
    installation of package ‘rgdal’ had non-zero exit status

Can you post the complete console output you get when you try to install the package? The excerpt you are showing only tell us that the installation has fail but it contains no useful information for troubleshooting.

Although, very likely you are missing system dependencies, have in mind that rgdal requires the following system libraries to be installed in your system

PROJ (>= 4.8.0, Download — PROJ 9.0.0 documentation) and GDAL (>= 1.11.4, Download — GDAL documentation), with versions either (A) PROJ < 6 and GDAL < 3 or (B) PROJ >= 6 and GDAL >= 3. For degraded PROJ 6 or 7 and GDAL < 3, use the configure argument '--with-proj_api="proj_api.h"'.

This is the output I receive:

install.packages("rgdal", lib="/Library/Frameworks/R.framework/Versions/4.1/Resources/library")

  There is a binary version available but
  the source version is later:
      binary source needs_compilation
rgdal 1.5-30 1.5-31              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘rgdal’

trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.5-31.tar.gz'
Content type 'application/x-gzip' length 4580883 bytes (4.4 MB)
==================================================
downloaded 4.4 MB

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /Library/Frameworks/R.framework/Resources
configure: CC: clang -mmacosx-version-min=10.13
configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++14
configure: CFLAGS: -Wall -g -O2
configure: CPPFLAGS: -I/usr/local/include
configure: CXXFLAGS: -Wall -g -O2
configure: LDFLAGS: -L/usr/local/lib
configure: LDFLAGS: -L/usr/local/lib
configure: CXX11 is: clang++ -mmacosx-version-min=10.13, CXX11STD is: -std=gnu++11
configure: CXX is: clang++ -mmacosx-version-min=10.13 -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.5-30
checking for /usr/bin/svnversion... no
configure: svn revision: 1171
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgdal’
Warning in install.packages :
  installation of package ‘rgdal’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/gd/101__cb91t959bt3pc908qlh0000gn/T/RtmpSi5eE1/downloaded_packages’

This is the output:

install.packages("rgdal", dependencies = TRUE)
Installing package into ‘/Users/angiegonzalezrosario/Library/R/x86_64/4.1/library’
(as ‘lib’ is unspecified)

  There is a binary version available but
  the source version is later:
      binary source needs_compilation
rgdal 1.5-30 1.5-31              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘rgdal’

trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.5-31.tar.gz'
Content type 'application/x-gzip' length 4580883 bytes (4.4 MB)
==================================================
downloaded 4.4 MB

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /Library/Frameworks/R.framework/Resources
configure: CC: clang -mmacosx-version-min=10.13
configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++14
configure: CFLAGS: -Wall -g -O2
configure: CPPFLAGS: -I/usr/local/include
configure: CXXFLAGS: -Wall -g -O2
configure: LDFLAGS: -L/usr/local/lib
configure: LDFLAGS: -L/usr/local/lib
configure: CXX11 is: clang++ -mmacosx-version-min=10.13, CXX11STD is: -std=gnu++11
configure: CXX is: clang++ -mmacosx-version-min=10.13 -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.5-30
checking for /usr/bin/svnversion... no
configure: svn revision: 1171
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Users/angiegonzalezrosario/Library/R/x86_64/4.1/library/rgdal’
Warning in install.packages :
  installation of package ‘rgdal’ had non-zero exit status

The downloaded source packages are in
	‘/private/var/folders/gd/101__cb91t959bt3pc908qlh0000gn/T/RtmpSi5eE1/downloaded_packages’

I was right in my assumption, you are missing the gdal system library, sadly I'm not a macOS user so I don't know how to install it on your system but maybe if you google it you can manage to do it on your own.

1 Like

Thank you, I will try.

I installed PROJ and GDAL. The packages sp, geos, sf were successfully installed. But I still receive this output:

install.packages("rgdal", lib="/Library/Frameworks/R.framework/Versions/4.1/Resources/library")

There is a binary version available but the source version is later:
binary source needs_compilation
rgdal 1.5-30 1.5-31 TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘rgdal’

trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.5-31.tar.gz'
Content type 'application/x-gzip' length 4580883 bytes (4.4 MB)

downloaded 4.4 MB

  • installing source package ‘rgdal’ ...
    ** package ‘rgdal’ successfully unpacked and MD5 sums checked
    ** using staged installation
    configure: R_HOME: /Library/Frameworks/R.framework/Resources
    configure: CC: clang -mmacosx-version-min=10.13
    configure: CXX: clang++ -mmacosx-version-min=10.13 -std=gnu++14
    configure: CFLAGS: -Wall -g -O2
    configure: CPPFLAGS: -I/usr/local/include
    configure: CXXFLAGS: -Wall -g -O2
    configure: LDFLAGS: -L/usr/local/lib
    configure: LDFLAGS: -L/usr/local/lib
    configure: CXX11 is: clang++ -mmacosx-version-min=10.13, CXX11STD is: -std=gnu++11
    configure: CXX is: clang++ -mmacosx-version-min=10.13 -std=gnu++11
    configure: C++11 support available
    configure: rgdal: 1.5-30
    checking for /usr/bin/svnversion... no
    configure: svn revision: 1171
    checking for gdal-config... no
    no
    configure: error: gdal-config not found or not executable.
    ERROR: configuration failed for package ‘rgdal’
  • removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgdal’
    Warning in install.packages :
    installation of package ‘rgdal’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/gd/101__cb91t959bt3pc908qlh0000gn/T/RtmpY7ZuZ6/downloaded_packages’

That is weird, are you sure you have installed compatible versions of PROJ and GDAL as per the instructions? Have you restarted your R session after installing those system libraries?

For some reason R is not recognizing them, you could try answering "no" when asked if you want to compile from source and see if the package works anyways with the libraries you have installed.

Also, if you are using a native arm64 version of R, are you using a native arm64 version of PROJ and GDAL?, it is very likely that both architectures have to match.

1 Like

Problem solved! I uninstalled GDAL and re-installed it. I then restarted the R session and when prompted to compile I answered 'no'. Now everything seems to be working.

Thank you!

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.