在install.packages()和restore()上执行renv失败

bjg7j2ky  于 2023-02-20  发布在  其他
关注(0)|答案(1)|浏览(249)

在新(伪)包和已经初始化renv的成熟包中,renvinstall.packages()restore()上失败。

  • 注意:为了避免触发垃圾邮件过滤器,我已将所有“https://”示例替换为“web”。*

install.packages()上的故障,例如dplyr

> install.packages("dplyr")
Retrieving 'web.cloud.r-project.org/bin/macosx/contrib/4.2/dplyr_1.1.0.tgz' ...
    OK [downloaded 1.5 Mb in 0.4 secs]
Retrieving 'web.cloud.r-project.org/bin/macosx/contrib/4.2/cli_3.6.0.tgz' ...
    OK [file is up to date]

[...]

Retrieving 'web.cloud.r-project.org/bin/macosx/contrib/4.2/withr_2.5.0.tgz' ...
    OK [file is up to date]
Installing cli [3.6.0] ...
    FAILED
Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) : 
  the condition has length > 1
In addition: Warning message:
In system2(R(), args, stdout = TRUE, stderr = TRUE) :
  running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 71

renv::restore()上的故障:

> renv::restore()
The following package(s) will be updated:

# CRAN ===============================
- KernSmooth            [2.23-20 -> 2.23-18]
- MASS                  [7.3-58.2 -> 7.3-53.1]

[...]

- zip                   [* -> 2.2.2]

# GitHub =============================
- staged.dependencies   [* -> remoteproject/staged.dependencies@HEAD]

Do you want to proceed? [y/N]: y
* Querying repositories for available binary packages ... Done!
* Querying repositories for available source packages ... Done!
Retrieving 'web.cran.microsoft.com/snapshot/2021-03-31/src/contrib/boot_1.3-27.tar.gz' ...
    OK [file is up to date]
Retrieving 'web.cran.microsoft.com/snapshot/2021-03-31/src/contrib/class_7.3-18.tar.gz' ...
    OK [file is up to date]

[...]

Retrieving 'web.cran.microsoft.com/snapshot/2021-03-31/src/contrib/visNetwork_2.0.9.tar.gz' ...
    OK [file is up to date]
Installing boot [1.3-27] ...
    FAILED
Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) : 
  the condition has length > 1
In addition: Warning messages:
1: could not retrieve available packages for url 'web.cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2' 
2: In system2(R(), args, stdout = TRUE, stderr = TRUE) :
  running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 71

会话信息:

> sessionInfo()

R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] MASS_7.3-58.2  compiler_4.2.1 tools_4.2.1    renv_0.16.0

从这里和其他论坛的答复来看,以下 * 可能 * 是有用的信息:

  1. getOption("repos")的输出:
> getOption("repos")
                                            CRAN                                             MRAN 
                   "web.cloud.r-project.org" "web.cran.microsoft.com/snapshot/2021-03-31"

1.直接从utils软件包安装的输出:

> utils::install.packages("dplyr")

Installing package into ‘/Users/dlei/Library/Caches/org.R-project.R/R/renv/library/project-01109165/R-4.2/x86_64-apple-darwin17.0’
(as ‘lib’ is unspecified)
also installing the dependencies ‘fansi’, ‘utf8’, ‘pkgconfig’, ‘withr’, ‘cli’, ‘generics’, ‘glue’, ‘lifecycle’, ‘magrittr’, ‘pillar’, ‘R6’, ‘rlang’, ‘tibble’, ‘tidyselect’, ‘vctrs’

Warning: unable to access index for repository web.cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2:
  cannot open URL 'web.cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2/PACKAGES'

trying URL 'web.cloud.r-project.org/bin/macosx/contrib/4.2/fansi_1.0.4.tgz'
Content type 'application/x-gzip' length 364195 bytes (355 KB)
==================================================
downloaded 355 KB

trying URL 'web.cloud.r-project.org/bin/macosx/contrib/4.2/utf8_1.2.3.tgz'
Content type 'application/x-gzip' length 196823 bytes (192 KB)
==================================================
downloaded 192 KB

[...]

The downloaded binary packages are in
    /var/folders/41/y38m8sw12871hpn_5nl9y88m0000gn/T//RtmpIwcHeu/downloaded_packages
  1. renv::diagnostics()的输出:
> renv::diagnostics()
Diagnostics Report [renv 0.16.0]
================================

# Session Info =======================
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] MASS_7.3-58.2  compiler_4.2.1 tools_4.2.1    renv_0.16.0   

# Project ============================
Project path: "~/Desktop/Git_Repos/project"

# Status =============================
The following package(s) do not appear to be used in this project:
               _
  BH             [1.75.0-0]
  KernSmooth     [2.23-18]
  [...]
  zip            [2.2.2]

Use `renv::snapshot()` to remove them from the lockfile.

The following package(s) are recorded in the lockfile, but not installed:
                      _
  DT                    [0.17]
  covr                  [3.5.1]
  [...]
  staged.dependencies   [remoteproject/staged.dependencies@HEAD]
  usethis               [2.1.6]

Use `renv::restore()` to install these packages.

The following package(s) are out of sync:

    Package   Lockfile Version   Library Version
         R6              2.5.0             2.5.1
        cli              3.4.1             3.6.0
      [...]
      vctrs              0.5.0             0.5.2

Use `renv::snapshot()` to save the state of your library to the lockfile.
Use `renv::restore()` to restore your library from the lockfile.

The following package(s) are used in the project, but are not installed:

    project.test
    projectdev

Consider installing these packages, and then using `renv::snapshot()`
to record these packages in the lockfile.

# Packages ===========================
                     Library Source Lockfile Source Path Dependency
BH                      <NA>   <NA> 1.75.0-0   CRAN <NA>       <NA>
DT                      <NA>   <NA>     0.17   CRAN <NA>     direct
[...]
zip                     <NA>   <NA>    2.2.2   CRAN <NA>       <NA>

[1]: /Users/dlei/Library/Caches/org.R-project.R/R/renv/library/project-01109165/R-4.2/x86_64-apple-darwin17.0
[2]: /Users/dlei/Desktop/Git_Repos/project/renv/sandbox/R-4.2/x86_64-apple-darwin17.0/84ba8b13               

# ABI ================================
* No ABI conflicts were detected in the set of installed packages.

# User Profile =======================
[no user profile detected]

# Settings ===========================
List of 10
 $ bioconductor.version     : chr(0) 
 $ external.libraries       : chr(0) 
 $ ignored.packages         : chr(0) 
 $ package.dependency.fields: chr [1:3] "Imports" "Depends" "LinkingTo"
 $ r.version                : chr(0) 
 $ snapshot.type            : chr "implicit"
 $ use.cache                : logi TRUE
 $ vcs.ignore.cellar        : logi TRUE
 $ vcs.ignore.library       : logi TRUE
 $ vcs.ignore.local         : logi TRUE

# Options ============================
List of 9
 $ defaultPackages                     : chr [1:6] "datasets" "utils" "grDevices" "graphics" ...
 $ download.file.method                : chr "libcurl"
 $ download.file.extra                 : NULL
 $ install.packages.compile.from.source: chr "interactive"
 $ pkgType                             : chr "both"
 $ repos                               : Named chr [1:2] "web.cloud.r-project.org" "web.cran.microsoft.com/snapshot/2021-03-31"
  ..- attr(*, "names")= chr [1:2] "CRAN" "MRAN"
 $ renv.consent                        : logi TRUE
 $ renv.project.path                   : chr "/Users/dlei/Desktop/Git_Repos/project"
 $ renv.verbose                        : logi TRUE

# Environment Variables ==============
HOME                        = /Users/dlei
LANG                        = en_CA.UTF-8
MAKE                        = make
R_LIBS                      = <NA>
R_LIBS_SITE                 = /Library/Frameworks/R.framework/Resources/site-library
R_LIBS_USER                 = /Users/dlei/Library/Caches/org.R-project.R/R/renv/library/project-01109165/R-4.2/x86_64-apple-darwin17.0:/Users/dlei/Desktop/Git_Repos/project/renv/sandbox/R-4.2/x86_64-apple-darwin17.0/84ba8b13
RENV_DEFAULT_R_ENVIRON      = <NA>
RENV_DEFAULT_R_ENVIRON_USER = <NA>
RENV_DEFAULT_R_LIBS         = <NA>
RENV_DEFAULT_R_LIBS_SITE    = /Library/Frameworks/R.framework/Resources/site-library
RENV_DEFAULT_R_LIBS_USER    = /Users/dlei/Library/R/x86_64/4.2/library
RENV_DEFAULT_R_PROFILE      = <NA>
RENV_DEFAULT_R_PROFILE_USER = <NA>
RENV_PROJECT                = /Users/dlei/Desktop/Git_Repos/project

# PATH ===============================
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/TeX/texbin
- 
- /Applications/RStudio.app/Contents/MacOS/postback

# Cache ==============================
There are a total of 0 package(s) installed in the renv cache.
Cache path: "~/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.2/x86_64-apple-darwin17.0"
  1. getOption("download.file.method")的输出:
> getOption("download.file.method")
[1] "libcurl"
  1. renv:::renv_download_method()的输出:
> renv:::renv_download_method()
[1] "curl"

1.根据RStudio community forum中的建议,我尝试将renv的下载方法从curl设置为libcurl,但得到了类似的错误:

> install.packages("dplyr")
Retrieving 'web.cloud.r-project.org/bin/macosx/contrib/4.2/dplyr_1.1.0.tgz' ...
    OK [downloaded 1.5 Mb in 0.3 secs]
Installing dplyr [1.1.0] ...
    FAILED
Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) : 
  the condition has length > 1
In addition: Warning messages:
1: could not retrieve available packages for url 'web.cran.microsoft.com/snapshot/2021-03-31/bin/macosx/contrib/4.2' 
2: In system2(R(), args, stdout = TRUE, stderr = TRUE) :
  running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 71
pgky5nke

pgky5nke1#

在错误消息中给出以下输出:

Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) : 
  the condition has length > 1
In addition: Warning message:
In system2(R(), args, stdout = TRUE, stderr = TRUE) :
  running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 71

您最近是否更新了计算机上的macOS?这看起来像是renv中的问题,尝试查询当前编译器可能会失败。
如果是这样,我相信您可以通过运行以下命令来解决此问题:

xcode-select --install

来自终端。

相关问题