简体   繁体   中英

MacOS M1: problems with installing sf in R - ERROR: compilation failed for package ‘classInt’; ERROR: configuration failed for package ‘units’

I am working on a MacOS Monterey with an M1 chip and have R 4.2.1 arm64 version (build 554). In the last two months I have come across an issue with install.package("sf") and others but will start with sf. When it asks to install from sources and I enter "No", the library won't load so I enter "Yes" and it gets an error (full error below).

ERROR: compilation failed for package 'classInt' ERROR: configuration failed for package 'units'

I have redownloaded the sf, classInt, units, and udunits2 packages from this link ( https://cran.r-project.org/web/packages/available_packages_by_name.html ), choosing the r re-release arm64 versions and it still doesn't work.

I tried following along with this https://github.com/r-spatial/sf/issues/1542 until the.configure command was not found in the terminal.

I then tried: brew install udunits in the Mac terminal using Homebrew and the error did not change.

I installed sf defining the library with udunits2 and it didn't work: install.packages("sf", configure.args = "--/Library/Frameworks/R.framework/Versions/4.2/Resources/library/udunits2")

I've spent over a full day troubleshooting and I'm not sure what to try next.

Any help is appreciated!

> install.packages("sf", configure.args = "--/Library/Frameworks/R.framework/Versions/4.2/Resources/library/udunits2")
also installing the dependencies ‘classInt’, ‘units’

Packages which are only available in source form, and may need compilation of C/C++/Fortran: ‘classInt’ ‘units’ ‘sf’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source packages ‘classInt’, ‘units’, ‘sf’

trying URL 'https://packagemanager.rstudio.com/all/latest/src/contrib/classInt_0.4-7.tar.gz'
Content type 'binary/octet-stream' length 440183 bytes (429 KB)
==================================================
downloaded 429 KB

trying URL 'https://packagemanager.rstudio.com/all/latest/src/contrib/units_0.8-0.tar.gz'
Content type 'binary/octet-stream' length 864506 bytes (844 KB)
==================================================
downloaded 844 KB

trying URL 'https://packagemanager.rstudio.com/all/latest/src/contrib/sf_1.0-8.tar.gz'
Content type 'binary/octet-stream' length 3532612 bytes (3.4 MB)
==================================================
downloaded 3.4 MB

* installing *source* package ‘classInt’ ...
** package ‘classInt’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/opt/R/arm64/bin/gfortran -mtune=native -fno-optimize-sibling-calls  -fPIC  -Wall -g -O2  -c fish1.f -o fish1.o
make: /opt/R/arm64/bin/gfortran: No such file or directory
make: *** [fish1.o] Error 1
ERROR: compilation failed for package ‘classInt’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/classInt’
Warning in install.packages :
  installation of package ‘classInt’ had non-zero exit status
* installing *source* package ‘units’ ...
** package ‘units’ successfully unpacked and MD5 sums checked
** using staged installation
configure: units: 0.8-0
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 clang++ -arch arm64 -std=gnu++14 accepts -g... yes
checking how to run the C++ preprocessor... clang++ -arch arm64 -std=gnu++14 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
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 for stdbool.h that conforms to C99... no
checking for _Bool... no
checking for error_at_line... no
checking for gcc... clang -arch arm64
checking whether we are using the GNU C compiler... yes
checking whether clang -arch arm64 accepts -g... yes
checking for clang -arch arm64 option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in `/private/var/folders/4k/f9g3wpqj2tv7rvsmhjtkbdl80000gn/T/Rtmp6uUpFo/R.INSTALL1845f210c2dbd/units':
configure: error: 
--------------------------------------------------------------------------------
  Configuration failed because libudunits2.so was not found. Try installing:
    * deb: libudunits2-dev (Debian, Ubuntu, ...)
    * rpm: udunits2-devel (Fedora, EPEL, ...)
    * brew: udunits (OSX)
  If udunits2 is already installed in a non-standard location, use:
    --configure-args='--with-udunits2-lib=/usr/local/lib'
  if the library was not found, and/or:
    --configure-args='--with-udunits2-include=/usr/include/udunits2'
  if the header was not found, replacing paths with appropriate values.
  You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------

See `config.log' for more details
ERROR: configuration failed for package ‘units’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/units’
Warning in install.packages :
  installation of package ‘units’ had non-zero exit status
ERROR: dependencies ‘classInt’, ‘units’ are not available for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/4k/f9g3wpqj2tv7rvsmhjtkbdl80000gn/T/RtmpPnpNin/downloaded_packages```

After installing gdal with homebrew, I used the link @wkl sent and the code install.packages('sf', configure.args = '--with-proj-include=/opt/homebrew/include/ --with-proj-lib=/opt/homebrew/lib/', configure.vars = 'GDAL_DATA=/opt/homebrew/opt/gdal/share/gdal/') I am still having problems with other packages but sf loaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM