Ok I am sorry that this kind of issue is probably frequently (perhaps too much) discussed here, but I just can't get to install sf on my system.
I have built both PROJ 6.1.0 and GDAL 3.0.0 on /opt/software. These are the only versions available on my system (i.e. I have no PROJ and GDAL libraries supplied by the OS).
I am trying to install sf under the root account so it's available for everyone. I am doing:
sudo su
R
remotes::install_github('r-spatial/sf')
````
Downloading GitHub repo r-spatial/sf@master
✔ checking for file ‘/tmp/RtmpWSeMFn/remotes6c945cbac559/r-spatial-sf-6e837a4/DESCRIPTION’ ...
─ preparing ‘sf’:
✔ checking DESCRIPTION meta-information ...
─ cleaning src
─ running ‘cleanup’
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘sf_0.7-5.tar.gz’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Then, I try to help sf locate what it needs by setting a PROJ_LIB environment variable, like shown below:
sudo su
export PROJ_LIB="/opt/software"
R
remotes::install_github('r-spatial/sf')
and I get a slightly different error message, but the package still won't build:
Downloading GitHub repo r-spatial/sf@master
✔ checking for file ‘/tmp/Rtmp3C4X3B/remotes5f777a73a167/r-spatial-sf-6e837a4/DESCRIPTION’ ...
─ preparing ‘sf’:
✔ checking DESCRIPTION meta-information ...
─ cleaning src
─ running ‘cleanup’
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘sf_0.7-5.tar.gz’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘sf’ ...
** using staged installation
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /opt/software/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.0.0
checking GDAL version >= 2.0.1... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /opt/software/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db
ERROR 1: PROJ: proj_create: Cannot find proj.db
ERROR 1: PROJ: proj_create: unrecognized format / unknown name
ERROR 1: Cannot instantiate source_crs
ERROR 6: Cannot find coordinate operations from `' to `'
no
configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?
ERROR: configuration failed for package ‘sf’
* removing ‘/usr/local/lib/R/site-library/sf’
* restoring previous ‘/usr/local/lib/R/site-library/sf’
Error in i.p(...) :
(converted from warning) installation of package ‘/tmp/Rtmp3C4X3B/file5f77351461cb/sf_0.7-5.tar.gz’ had non-zero exit status
(long sigh...) As of now, is there any way to install sf along with that PROJ/GDAL combo?
Please see also #1070 and in particular the use of --configure-args as argument to an install. This is not supposed to work without instructing the R installer where the system requirements are to be found.
Many thanks for the feedback, @edzer. Refining --configure-args was definitely helpful, but the crucial step was setting PKG_CONFIG_PATH:
sudo su
export PKG_CONFIG_PATH="/opt/software/lib/pkgconfig"
R
remotes::install_github('r-spatial/sf', configure.args=("--with-gdal-config=/opt/software/bin/gdal-config --with-proj-lib=/opt/software/lib --with-proj-include=/opt/software/include --with-proj-share=/opt/software/share/proj --with-proj-data=/opt/software/share/proj"))
I'm closing this now but feel free to reopen it if you need to add something.
Similar problem here, but that did not work for me on MacOS Catalina. Following the instructions above, insu:
remotes::install_github('r-spatial/sf', configure.args=("--with-gdal-config=/opt/software/bin/gdal-config --with-proj-lib=/opt/software/lib --with-proj-include=/opt/software/include --with-proj-share=/opt/software/share/proj --with-proj-data=/opt/software/share/proj"))
Downloading GitHub repo r-spatial/sf@master
✔ checking for file ‘/private/tmp/RtmpbT5xNF/remotesf0802ebbd3a7/r-spatial-sf-5287ae1/DESCRIPTION’ ...
^R
─ preparing ‘sf’:
✔ checking DESCRIPTION meta-information ...
─ cleaning src
─ running ‘cleanup’
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘sf_0.9-2.tar.gz’
* installing *source* package ‘sf’ ...
** using staged installation
qconfigure: CC: clang
configure: CXX: clang++ -std=gnu++11
configure: gdal-config set to /opt/software/bin/gdal-config
checking gdal-config exists... no
configure: error: gdal-config not found - configure argument error.
ERROR: configuration failed for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf’
uError: Failed to install 'sf' from GitHub:
(converted from warning) installation of package ‘/tmp/RtmpbT5xNF/filef080391f2773/sf_0.9-2.tar.gz’ had non-zero exit status
Some other info:
gdal-config --version
2.4.4
pkg-config proj --modversion
7.0.0
gdal-config --ogr-enabled
yes
Thanks :)
Most helpful comment
Many thanks for the feedback, @edzer. Refining
--configure-argswas definitely helpful, but the crucial step was settingPKG_CONFIG_PATH:I'm closing this now but feel free to reopen it if you need to add something.