2

我在sf通过renv. 我已经在我的 Mac 中从源代码安装了 R,一切都很好。我能够安装rgdalsf通过,install.packages但无法使用renv. proj_api.h问题是即使我指出了完整路径,安装脚本也找不到标头。

install.packages("sf")

一切正常,无需进一步干预。内renv

> renv::activate()
> renv::install("sf")
....
checking proj_api.h usability... no
checking proj_api.h presence... no
checking for proj_api.h... no
configure: error: proj_api.h not found in standard or given locations.
ERROR: configuration failed for package ‘sf’
....

标题proj_api.h在 下/usr/local/include/,所以按照我试过的文档:

options(configure.args = c(sf="--with-proj-include=/usr/local/include/"))

在安装之前,但结果相同。我不知道接下来要尝试什么。我不明白为什么renv找不到路径以及为什么没有找到路径(位置非常标准)。即使我通过完整路径,也无法理解如何找不到标头。

没有的环境变量renv

__CF_USER_TEXT_ENCODING
                        0xAF76729:0x0:0x0
_CE_CONDA               
_CE_M                   
CLICOLOR                1
COLUMNS                 117
CONDA_EXE               /Users/52488/miniconda3/bin/conda
CONDA_PYTHON_EXE        /Users/52488/miniconda3/bin/python
CONDA_SHLVL             0
DISPLAY                 /private/tmp/com.apple.launchd.heGiCHqO77/org.xquartz:0
DYLD_FALLBACK_LIBRARY_PATH
                        /Users/52488/Rinstallation/R-4.0.4/lib:/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home/lib/server
EDITOR                  vi
HOME                    /Users/52488
LC_ALL                  en_US.UTF-8
LC_CTYPE                UTF-8
LINES                   30
LN_S                    ln -s
LOGNAME                 52488
LSCOLORS                gxBxhxDxfxhxhxhxhxcxcx
MAKE                    make
PAGER                   /usr/bin/less
PATH                    /Users/52488/miniconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware
                        Fusion.app/Contents/Public:/opt/X11/bin
PWD                     /Users/52488
R_ARCH                  
R_BROWSER               /usr/bin/open
R_BZIPCMD               /usr/bin/bzip2
R_DOC_DIR               /Users/52488/Rinstallation/R-4.0.4/doc
R_GZIPCMD               /usr/bin/gzip
R_HOME                  /Users/52488/Rinstallation/R-4.0.4
R_INCLUDE_DIR           /Users/52488/Rinstallation/R-4.0.4/include
R_LIBS_SITE             
R_LIBS_USER             ~/Library/R/4.0/library
R_PAPERSIZE             a4
R_PDFVIEWER             /usr/local/bin/evince
R_PLATFORM              x86_64-apple-darwin17.0
R_PRINTCMD              lpr
R_RD4PDF                times,inconsolata,hyper
R_SESSION_TMPDIR        /var/folders/jb/vpf_9ht52zj_0qk_3r1f0dlw5gfss9/T//Rtmp40nNZi
R_SHARE_DIR             /Users/52488/Rinstallation/R-4.0.4/share
R_STRIP_SHARED_LIB      strip -x
R_STRIP_STATIC_LIB      strip -S
R_SYSTEM_ABI            macos,gcc,gxx,gfortran,gfortran
R_TEXI2DVICMD           /usr/local/bin/texi2dvi
R_UNZIPCMD              /usr/bin/unzip
R_ZIPCMD                /usr/bin/zip
SED                     /usr/bin/sed
SHELL                   /usr/local/bin/bash
SHLVL                   1
SSH_AUTH_SOCK           /private/tmp/com.apple.launchd.1OK1KoT1o5/Listeners
TAR                     /usr/bin/tar
TERM                    xterm-256color
TERM_PROGRAM            Apple_Terminal
TERM_PROGRAM_VERSION    433
TERM_SESSION_ID         2BA70166-937D-47AB-B6B6-23316D978294
TMPDIR                  /var/folders/jb/vpf_9ht52zj_0qk_3r1f0dlw5gfss9/T/
USER                    52488
XPC_FLAGS               0x0
XPC_SERVICE_NAME        0

renv

__CF_USER_TEXT_ENCODING
                        0xAF76729:0x0:0x0
_CE_CONDA               
_CE_M                   
CLICOLOR                1
COLUMNS                 117
CONDA_EXE               /Users/52488/miniconda3/bin/conda
CONDA_PYTHON_EXE        /Users/52488/miniconda3/bin/python
CONDA_SHLVL             0
DISPLAY                 /private/tmp/com.apple.launchd.heGiCHqO77/org.xquartz:0
DYLD_FALLBACK_LIBRARY_PATH
                        /Library/Frameworks/GDAL.framework/unix/lib:/Users/52488/Rinstallation/R-4.0.4/lib:/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home/lib/server
EDITOR                  vi
HOME                    /Users/52488
LC_ALL                  en_US.UTF-8
LC_CTYPE                UTF-8
LINES                   30
LN_S                    ln -s
LOGNAME                 52488
LSCOLORS                gxBxhxDxfxhxhxhxhxcxcx
MAKE                    make
PAGER                   /usr/bin/less
PATH                    /Users/52488/miniconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware
                        Fusion.app/Contents/Public:/opt/X11/bin
PWD                     /Users/52488/Documents/staffing
R_ARCH                  
R_BROWSER               /usr/bin/open
R_BZIPCMD               /usr/bin/bzip2
R_DOC_DIR               /Users/52488/Rinstallation/R-4.0.4/doc
R_GZIPCMD               /usr/bin/gzip
R_HOME                  /Users/52488/Rinstallation/R-4.0.4
R_INCLUDE_DIR           /Users/52488/Rinstallation/R-4.0.4/include
R_LIBS_SITE             
R_LIBS_USER             /Users/52488/Documents/staffing/renv/library/R-4.0/x86_64-apple-darwin17.0:/private/var/folders/jb/vpf_9ht52zj_0qk_3r1f0dlw5gfss9/T/Rtmpm4f15L/renv-system-library
R_PAPERSIZE             a4
R_PDFVIEWER             /usr/local/bin/evince
R_PLATFORM              x86_64-apple-darwin17.0
R_PRINTCMD              lpr
R_RD4PDF                times,inconsolata,hyper
R_SESSION_TMPDIR        /var/folders/jb/vpf_9ht52zj_0qk_3r1f0dlw5gfss9/T//Rtmpm4f15L
R_SHARE_DIR             /Users/52488/Rinstallation/R-4.0.4/share
R_STRIP_SHARED_LIB      strip -x
R_STRIP_STATIC_LIB      strip -S
R_SYSTEM_ABI            macos,gcc,gxx,gfortran,gfortran
R_TEXI2DVICMD           /usr/local/bin/texi2dvi
R_UNZIPCMD              /usr/bin/unzip
R_ZIPCMD                /usr/bin/zip
RENV_DEFAULT_R_ENVIRON
                        <NA>
RENV_DEFAULT_R_ENVIRON_USER
                        <NA>
RENV_DEFAULT_R_LIBS     <NA>
RENV_DEFAULT_R_LIBS_SITE
                        
RENV_DEFAULT_R_LIBS_USER
                        ~/Library/R/4.0/library
RENV_DEFAULT_R_PROFILE
                        <NA>
RENV_DEFAULT_R_PROFILE_USER
                        <NA>
RENV_PROJECT            /Users/52488/Documents/staffing
RETICULATE_MINICONDA_PYTHON_ENVPATH
                        /Users/52488/Documents/staffing/renv/python/r-reticulate
SDKROOT                 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
SED                     /usr/bin/sed
SHELL                   /usr/local/bin/bash
SHLVL                   1
SSH_AUTH_SOCK           /private/tmp/com.apple.launchd.1OK1KoT1o5/Listeners
TAR                     /usr/bin/tar
TERM                    xterm-256color
TERM_PROGRAM            Apple_Terminal
TERM_PROGRAM_VERSION    433
TERM_SESSION_ID         34A286FD-8106-4F78-88F9-8913E45EDCDE
TMPDIR                  /var/folders/jb/vpf_9ht52zj_0qk_3r1f0dlw5gfss9/T/
USER                    52488
XPC_FLAGS               0x0
XPC_SERVICE_NAME        0

三个变量不同,但我猜这很正常:

[1] "PWD"              "R_LIBS_USER"      "R_SESSION_TMPDIR"

当然,有些RENV*变量只存在于renv案例中。

进一步挖掘并从这个问题中获得灵感,我检查了gcc. 视情况而异renv

renv

> system("echo | gcc -Wp,-v -x c++ - -fsyntax-only", intern=TRUE)
clang -cc1 version 12.0.0 (clang-1200.0.32.29) default target x86_64-apple-darwin19.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1
 /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
 /Library/Developer/CommandLineTools/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.

没有renv

> system("echo | gcc -Wp,-v -x c++ - -fsyntax-only", intern=TRUE)
clang -cc1 version 12.0.0 (clang-1200.0.32.29) default target x86_64-apple-darwin19.6.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1
 /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include
 /Library/Developer/CommandLineTools/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks (framework directory)
End of search list.

很明显,renv标准内部/usr/local/include不存在(其他路径也存在一些差异)。这是为什么?我该如何解决?

4

1 回答 1

0

我刚刚经历过这个。我也安装了所有东西install.packages('sf'),它工作得很好,直到今天我需要在 renv 环境中工作。

这对我有帮助(假设您已安装 brew):

  1. brew install gdal --HEAD
  2. brew install gdal
  3. brew install proj

我不知道为什么sf以前实际工作过,可能 R 将这些二进制文件安装在 r-internal 的某个地方。

于 2021-11-02T15:15:22.250 回答