Error Report: Installation Issue with `sf` Package
Closed this issue · 5 comments
Error Report: Installation Issue with sf
Package
Summary
I am experiencing difficulties installing the sf
package in my R environment. The installation process fails when attempting to run compiled C programs during the build. Below is the detailed description of the issue, including system information and steps I have taken to diagnose and attempt to resolve the problem.
System Information
- Operating System: Ubuntu 22.04
- R Version: 4.4
- sf Package Version: 1.0-19
- Conda Environment: Not Used.
- GDAL Version: 3.4.1
- GEOS Version: 3.10.2
- PROJ Version: 8.2.1
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.5 LTS
Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Asia/Shanghai
tzcode source: system (glibc)
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] remotes_2.5.0
loaded via a namespace (and not attached):
[1] processx_3.8.4 compiler_4.4.0 R6_2.5.1 cli_3.6.3 tools_4.4.0 curl_5.2.3 desc_1.4.3
[8] callr_3.7.6 ps_1.8.0 pkgbuild_1.4.4 rlang_1.1.4 pak_0.8.0 sessioninfo_1.2.2
Error Details
During installation, I encounter the following error:
configure: error: cannot run C compiled programs. If you meant to cross compile, use --host'.
Seeconfig.log' for more details ERROR: configuration failed for package ‘sf’
> pak::pkg_install("r-spatial/sf")
→ Will install 1 package.
→ The package (0 B) is cached.
+ sf 1.0-19 [bld][cmp] (GitHub: b8e12d8) + ✔ libgdal-dev, ✔ gdal-bin, ✔ libgeos-dev, ✔ libproj-dev, ✔ libsqlite3-dev
✔ All system requirements are already installed.
ℹ No downloads are needed, 1 pkg is cached
ℹ Building sf 1.0-19
✖ Failed to build sf 1.0-19 (3.5s)
Error:
! ! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package sf.
Full installation output:
* installing *source* package ‘sf’ ...
staged installation is only possible with locking
** using non-staged installation
configure: CC: /home/fengbx/anaconda3/envs/FBX/bin/x86_64-conda_cos6-linux-gnu-cc
configure: CXX: g++ -std=gnu++17
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.4.1
checking GDAL version >= 2.0.1... yes
checking for gcc... /home/fengbx/anaconda3/envs/FBX/bin/x86_64-conda_cos6-linux-gnu-cc
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 the compiler supports GNU C... yes
checking whether /home/fengbx/anaconda3/envs/FBX/bin/x86_64-conda_cos6-linux-gnu-cc accepts -g... yes
checking for /home/fengbx/anaconda3/envs/FBX/bin/x86_64-conda_cos6-linux-gnu-cc option to enable C11 features... none needed
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available for running:... yes
configure: GDAL: 3.4.1
configure: pkg-config proj exists, will use it
configure: using proj.h.
configure: PROJ: 8.2.1
checking PROJ: checking whether PROJ and sqlite3 are available for linking:... yes
proj_conf_test.c:3:10: fatal error: proj.h: No such file or directory
#include <proj.h>
^~~~~~~~
compilation terminated.
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.10.2
checking GEOS version >= 3.4.0... yes
checking for geos_c.h... no
configure: error: geos_c.h not found in given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/tmp/RtmpFnEmIS/pkg-lib3739a251ff4cd8/sf’
Hide Traceback
▆
1. └─pak::pkg_install("r-spatial/sf")
2. └─pak:::remote(...)
3. └─err$throw(res$error)
The build fails specifically at the point where the C compiler attempts to run compiled programs.
Steps Taken
- Verified that
geos_c.h
andproj.h
exist in/usr/include
. - Set environment variables:
C_INCLUDE_PATH
andCPLUS_INCLUDE_PATH
to/usr/include
.- Ensured
PKG_CONFIG_PATH
includes necessary directories for GEOS and PROJ.
- Confirmed the presence of all necessary development libraries (
libgdal-dev
,libgeos-dev
,libproj-dev
). - Attempted to modify the compiler and linker paths to system GCC.
- Reviewed
config.log
for any additional clues to the problem. - Attempted installation within and outside of a Conda environment.
Request for Assistance
Given the detailed steps and attempts above, could you provide guidance on additional checks or configurations necessary to resolve this installation issue?
Thank you for your assistance.
$ sudo find /usr/include -name "geos_c.h"
/usr/include/geos_c.h
$ sudo find /usr/include -name "proj.h"
/usr/include/proj.h
Attempted installation within and outside of a Conda environment.
Please use install.packages()
, not pak
; please use nothing from conda; if you must use conda, please ask help from the conda people. As you are using conda, is there a reason why you don't install sf as binary package from conda?
Thank you for your prompt response. I apologize for any misunderstandings in our previous communication. Please allow me to clarify that I am using R in my main system environment and not in a Conda environment. The paths mentioned in my error report might have led to some confusion.
I used install.packages(), and here is the result:
> install.packages("sf")
Installing package into ‘/home/fengbx/R/x86_64-pc-linux-gnu-library/4.4’
(as ‘lib’ is unspecified)
trying URL '[https://cran.rstudio.com/src/contrib/sf_1.0-18.tar.gz](vscode-file://vscode-app/Applications/Positron.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html#)'
Content type 'application/x-gzip' length 3804756 bytes (3.6 MB)
==================================================
downloaded 3.6 MB
* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: /home/fengbx/anaconda3/envs/FBX/bin/x86_64-conda_cos6-linux-gnu-cc
configure: CXX: g++ -std=gnu++17
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.4.1
checking GDAL version >= 2.0.1... yes
checking for gcc... /home/fengbx/anaconda3/envs/FBX/bin/x86_64-conda_cos6-linux-gnu-cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /home/fengbx/anaconda3/envs/FBX/bin/x86_64-conda_cos6-linux-gnu-cc accepts -g... yes
none needed
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/pcs.csv readable... no
yes
checking GDAL: checking whether PROJ is available for running:... yes
configure: GDAL: 3.4.1
configure: pkg-config proj exists, will use it
configure: using proj.h.
configure: PROJ: 8.2.1
yes
proj_conf_test.c:3:10: fatal error: proj.h: No such file or directory
#include <proj.h>
^~~~~~~~
compilation terminated.
checking for geos-config... /usr/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.10.2
checking GEOS version >= 3.4.0... yes
checking for geos_c.h... no
configure: error: geos_c.h not found in given locations.
ERROR: configuration failed for package ‘sf’
* removing ‘/home/fengbx/R/x86_64-pc-linux-gnu-library/4.4/sf’
The downloaded source packages are in
‘/tmp/RtmpZna9k6/downloaded_packages’
Warning message:
In install.packages("sf") :
installation of package ‘sf’ had non-zero exit status
The failure occurs when running the compiled C programs.
System information:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
gcc version
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
OK, the problem is solved. I think it is a system permission problem.
When I use sudo
run R
sudo /usr/local/bin/R
Then:
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (sf)
The downloaded source packages are in
‘/tmp/Rtmp2VxvLx/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done