1

I cannot install rgdal on MacBook with Catalina. I installed r using Brew and r is up to date.

I have the gdal framework installed. I've tried to install rgdal from source, but I keep getting an error that I don't know how to fix:

> install.packages('rgdal', type="source")
Installing package into ‘/Users/jobentley/Library/R/4.0/library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.5-8.tar.gz'
Content type 'application/x-gzip' length 2299235 bytes (2.2 MB)
==================================================
downloaded 2.2 MB

^~~~~~~~~~~~

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /usr/local/Cellar/r/4.0.0_1/lib/R
configure: CC: clang
configure: CXX: clang++
configure: C++11 support available
configure: rgdal: 1.5-8
checking for /usr/bin/svnversion... yes
configure: svn revision: 990
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.4.4
checking C++11 support for GDAL >= 2.3.0... yes
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: /usr/local/Cellar/gdal/2.4.4_7/share/gdal/stateplane.csv readable... yes
./configure: line 2458: 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/usr/local/Cellar/gdal/2.4.4_7/include
configure: PROJ LIBS:  -lproj
checking PROJ header API:... proj.h
./configure: line 2578: test: =: unary operator expected
checking Using GDAL < 3 with PROJ >= 6... ./configure: line 3892: test: too many arguments
no
checking PROJ version >= 4.8.0... ./configure: line 3908: test: -lt: unary operator expected
yes
./configure: line 3917: test: -lt: unary operator expected
./configure: line 3979: test: =: unary operator expected
checking PROJ: proj.db found and readable... yes
./configure: line 4119: test: =: unary operator expected
./configure: line 4196: test: =: unary operator expected
./configure: line 4261: test: : integer expression expected
./configure: line 4402: test: =: unary operator expected
./configure: line 4425: test: =: unary operator expected
./configure: line 4429: test: : integer expression expected
configure: Package CPP flags:  -I/usr/local/Cellar/gdal/2.4.4_7/include
configure: Package LIBS:  -L/usr/local/Cellar/gdal/2.4.4_7/lib -lgdal -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
clang++ -std=gnu++11 -I"/usr/local/Cellar/r/4.0.0_1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal/2.4.4_7/include -I'/usr/local/Cellar/r/4.0.0_1/lib/R/library/sp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include   -fPIC  -g -O2  -c OGR_write.cpp -o OGR_write.o
clang++ -std=gnu++11 -I"/usr/local/Cellar/r/4.0.0_1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal/2.4.4_7/include -I'/usr/local/Cellar/r/4.0.0_1/lib/R/library/sp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include   -fPIC  -g -O2  -c gdal-bindings.cpp -o gdal-bindings.o
clang -I"/usr/local/Cellar/r/4.0.0_1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal/2.4.4_7/include -I'/usr/local/Cellar/r/4.0.0_1/lib/R/library/sp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include   -fPIC  -g -O2  -c init.c -o init.o
clang -I"/usr/local/Cellar/r/4.0.0_1/lib/R/include" -DNDEBUG -I/usr/local/Cellar/gdal/2.4.4_7/include -I'/usr/local/Cellar/r/4.0.0_1/lib/R/library/sp/include' -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include   -fPIC  -g -O2  -c inverser.c -o inverser.o



inverser.c:5:10: fatal error: 'projects.h' file not found
#include <projects.h>

1 error generated.
make: *** [inverser.o] Error 1
ERROR: compilation failed for package ‘rgdal’
* removing ‘/Users/jobentley/Library/R/4.0/library/rgdal’
Warning in install.packages :
  installation of package ‘rgdal’ had non-zero exit status

The downloaded source packages are in

‘/private/var/folders/3h/pv_csl_s58ldssp2mxgnlgqc0000gp/T/Rtmp21KjJ2/downloaded_packages’

Any ideas on what to do?

1
  • I've added the "R" tag which might get you some more attention!
    – Spacedman
    Commented Jun 8, 2020 at 7:18

1 Answer 1

3

I had the same problem, and here's how I fixed it. (ubuntu 18.04 with R version 3.6.3 (2020-02-29) -- "Holding the Windsock". I have GDAL 3.0.4, released 2020/01/28, installed on the system.)

The issue seems to be with version rgdal_1.5-8. A bug in this version perhaps. I just installed 1.4-8 instead.

require(devtools)
install_version("rgdal", version = "1.4-8", repos = "http://cran.us.r-project.org")
1
  • This worked! Thank you so much! Commented Jun 8, 2020 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.