簡體   English   中英

R 在 renv 中安裝 package stringi

[英]R install package stringi in renv

我正在嘗試使用renv::install()安裝 package stringi。

通常,我會使用

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

指定 icudt61l.zip 依賴的位置。 我怎樣才能在 renv 中做到這一點?

我試圖在 my.Rprofile 中添加ICUDT_DIR='path/to/icudt61l.zip/'但它沒有用。

知道如何告訴 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]
install.packages("stringi", configure.vars="ICUDT_DIR=<icudt_dir>")

只需使用此命令,即可從本地加載 ICUDT。 如果你運行這一切都有錯誤,在icudt中無法連接。你應該按照這個https://raw.githubusercontent.com/gagolews/stringi/master/INSTALL

像這樣跟隨:

ICU 數據庫和無法上網

請注意,如果您選擇使用我們的 ICU4C 捆綁包,那么 - 默認情況下 - ICU 數據庫將從我們的鏡像服務器之一下載。 但是,如果您已經下載了適合您的平台(大/小端)的icudt*.zip版本,您可能希望通過調用以下方式安裝 package:

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

此外,如果您在嘗試安裝 stringi 的機器上無法訪問Internet,請嘗試獲取 package 的最新開發版本,因為它與ICU數據存檔一起提供。 您可以通過省略.Rbuildignore文件中的一些相關行來構建包含所有必需 ICU 數據文件(供離線使用)的可分發源 package。 以下命令序列應該可以解決問題:

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

假設 package 的最新開發版本編號為 xyz,則在當前工作目錄中創建一個名為stringi_x.yztar.gz的文件。 現在可以通過執行以下命令安裝 package(源包可以通過scp等傳播):

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

或者,從 R session 中調用:

install.packages("stringi_x.y.z.tar.gz", repos=NULL)

?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"))

應該有希望讓你擺脫困境。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM