2

我正在尝试使用renv::install().

通常,我会使用

install.packages('stringi', configure.vars='ICUDT_DIR=path/to/icudt61l.zip/')

指定 icudt61l.zip 依赖项的位置。我怎样才能在 renv 中做到这一点?

我试图添加ICUDT_DIR='path/to/icudt61l.zip/'我的 .Rprofile 但它没有用。

知道如何告诉 renv ICU 在哪里安装 stringi 吗?

这是我得到的错误

> renv::install("stringi")
...
Installing stringi [1.6.2] ...
    FAILED
Error installing package 'stringi':
===================================
...
** package ‘stringi’ successfully unpacked and MD5 sums checked
** using staged installation
checking for R_HOME... /opt/R/4.0.3/lib/R
checking for R... /opt/R/4.0.3/lib/R/bin/R
...
checking with pkg-config for the system ICU4C... 50.1.2
checking for ICU4C >= 55... no
*** ICU4C 50.1.2 has been detected
*** Minimal requirements, i.e., ICU4C >= 55, are not met
*** Trying with 'standard' fallback flags
checking whether an ICU4C-based project can be built... yes
checking programmatically for sufficient U_ICU_VERSION_MAJOR_NUM... no
*** This version of ICU4C cannot be used.
*** Using the ICU 69 bundle.
checking whether we may compile src/icu69/common/putil.cpp... yes
checking whether we may compile src/icu69/i18n/number_affixutils.cpp... yes
checking whether alignof(std::max_align_t) is available... no
checking whether alignof(::max_align_t) is available... yes
checking whether the ICU data library can be downloaded... downloading the ICU data library (icudt)
output path: icu69/data/icu4c-69_1-data-bin-l.zip
trying URL 'https://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip'
Error in download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb"): cannot open URL 'https://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip'

trying URL 'http://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip'
Error in download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb"): cannot open URL 'http://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip'

icudt download failed
Error: Stopping on error
In addition: Warning messages:
1: In download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb") :
  URL 'https://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip': status was 'Couldn't connect to server'
2: In download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb") :
  URL 'http://raw.githubusercontent.com/gagolews/stringi/master/src/icu69/data/icu4c-69_1-data-bin-l.zip': status was 'Couldn't connect to server'
Execution halted
*** *********************************************************************
*** stringi cannot be built.
*** Failed to download the ICU data library (icudt). Stopping now.
*** For build environments that have no internet access,
*** see the INSTALL file for a workaround.
*** *********************************************************************
ERROR: configuration failed for package ‘stringi’
* removing ‘/var/projects/iml/GDCFA21N/avertie_test/renv/staging/2/stringi’
Error: install of package 'stringi' failed [error code 1]
4

2 回答 2

2
install.packages("stringi", configure.vars="ICUDT_DIR=<icudt_dir>")

只需使用此命令,即可从本地加载 ICUDT。如果你运行这一切都有错误,在 icudt 中无法连接。你应该遵循这个 https://raw.githubusercontent.com/gagolews/stringi/master/INSTALL

像这样跟随:

ICU 数据库和无法上网

请注意,如果您选择使用我们的 ICU4C 捆绑包,那么 - 默认情况下 - ICU 数据库将从我们的镜像服务器之一下载。但是,如果您已经下载了icudt*.zip适合您平台的版本(大/小端),您可能希望通过调用来安装该软件包:

install.packages("stringi", configure.vars="ICUDT_DIR=<icudt_dir>")

此外,如果您在尝试安装 stringi 的机器上无法访问ICUInternet,请尝试获取该软件包的最新开发版本,因为它与数据存档一起提供。您可以通过省略文件中的一些相关行来构建包含所有必需的 ICU 数据文件(供离线使用)的可分发源包.Rbuildignore。以下命令序列应该可以解决问题:

wget https://github.com/gagolews/stringi/archive/master.zip -O stringi.zip
unzip stringi.zip
sed -i '/\/icu..\/data/d' stringi-master/.Rbuildignore
R CMD build stringi-master

假设该软件包的最新开发版本编号为 xyz,stringi_x.y.z.tar.gz则在当前工作目录中创建一个名为的文件。现在可以通过执行以下命令来安装包(源包可以通过 scpetc. 传播):

R CMD INSTALL stringi_x.y.z.tar.gz

或者,从 R 会话中调用:

install.packages("stringi_x.y.z.tar.gz", repos=NULL)
于 2021-06-08T08:15:09.153 回答
1

来自?renv::install

Package Configuration:

     Many R packages have a 'configure' script that needs to be run to
     prepare the package for installation. Arguments and environment
     variables can be passed through to those scripts in a manner
     similar to install.packages. In particular, the R options
     'configure.args' and 'configure.vars' can be used to map package
     names to their appropriate configuration. For example:

     # installation of RNetCDF may require us to set include paths for netcdf
     configure.args = c(RNetCDF = "--with-netcdf-include=/usr/include/udunits2"))
     options(configure.args = configure.args)
     renv::install("RNetCDF")

     Similarly, additional flags that should be passed to R CMD INSTALL
     can be set via the 'install.opts' R option:

     # installation of R packages using the Windows Subsystem for Linux
     # may require the `--no-lock` flag to be set during install
     options(install.opts = "--no-lock")
     renv::install("xml2")

设置类似:

options(configure.vars = list(stringi = "ICUDT_DIR=path/to/icudt61l.zip"))

应该有希望让你摆脱困境。

于 2021-05-18T18:26:24.830 回答