'Errors installing rgdal MacOS - still

There have been many posts regarding problems installing the rgdal package. I've been through lots of them, have tried many of the recommended solutions, but still am having problems. I'm using R4.0.3 on a Mac under OS10.15.7 (Catalina). I use MacPorts for package management. I included the R command I used and the results below, but will highlight what seem to be the problems first:

  1. Error "Failed to locate 'svnversion'. I don't understand this because the previous line in the output reads "checking for /usr/bin/svnversion... yes" and using the terminal "which svnversion" yields "/usr/bin/svnversion". The subsequent message about the command line tools has been discussed elsewhere and I have followed the recommendation to remove the COMMAND_TOOLS directory and install the standalone version; this makes no difference.

  2. gdal-config? It exists and is executable, but this text "cat: inst/SVN_VERSION: No such file or directory" appears before the system answers "yes" to the check of gdal-config usability. Looking for that particular message across the net yielded nothing helpful (to me, at least).

  3. pkg-config proj? I installed proj using MacPorts

    % sudo port install proj

Password: ---> Cleaning proj ---> Scanning binaries for linking errors ---> No broken files found.
---> No broken ports found.

But the system seems to be looking for proj.pc. What is that?

  1. pkg-config: command not found but

    % which pkg-config

/opt/local/bin/pkg-config

I've been playing with this for days and would really appreciate some help, even it is just pointing me to a previous post I may have missed.

From within R I issue the command

install.packages("rgdal", type="source", repos="http://R-Forge.R-project.org", configure.args=c('--with-gdal-config=/opt/local/bin/gdal-config'))

Which results in:

Installing package into ‘/Users/blesht/Library/R/4.0/library’
(as ‘lib’ is unspecified)
trying URL 'http://R-Forge.R-project.org/src/contrib/rgdal_1.5-19.tar.gz'
Content type 'application/x-gzip' length 4375551 bytes (4.2 MB)
==================================================
downloaded 4.2 MB

* installing *source* package ‘rgdal’ ...
** 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++11
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-19
checking for /usr/bin/svnversion... yes
svnversion: error: Failed to locate 'svnversion'.
svnversion: error: The subversion command line tools are no longer provided by Xcode.
configure: svn revision: 
configure: gdal-config set to /opt/local/bin/gdal-config
checking gdal-config exists... yes
checking gdal-config executable... yes
checking gdal-config usability... cat: inst/SVN_VERSION: No such file or directory
yes
configure: GDAL: 3.2.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/local/share/gdal/stateplane.csv readable... yes
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/local/include
configure: PROJ LIBS:  -lproj
checking PROJ header API:... yes
configure: API to be used as yet undetermined, searching ...
./configure: line 2509: pkg-config: command not found
configure: error: API to be used not found
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Users/blesht/Library/R/4.0/library/rgdal’

The downloaded source packages are in
    ‘/private/var/folders/l1/qvc9dqvn42b2y88cbyq_m3yw0000gn/T/RtmpsbrzxM/downloaded_packages’
Warning message:
In install.packages("rgdal", type = "source", repos = "http://R-Forge.R-project.org",  :
  installation of package ‘rgdal’ had non-zero exit status


Solution 1:[1]

I was able to install the rgdal package after much trouble.

Mac OS X 10.15.7 (Catalina)

R version 4.1.1 (2021-08-10)

RStudio version 1.4.1717

  1. from inside of RStudio using the Tools/Install Packages menu, chose CRAN repository, and install "sf" package

  2. then do the same from CRAN repository to install "rgdal"

These steps installed packages:

sf 1.0-2

rgdal 1.5-23

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1