【问题标题】:remotes::install_github can't find a dependency that is presentremotes::install_github 找不到存在的依赖项
【发布时间】:2021-02-28 07:46:54
【问题描述】:

受 Miles McBain 的 drake video 启发,我想安装 fnmate 包/RStudio 插件。但是remotes::install_github 坚持说我没有magrittr,而事实上我有。

我使用在环境变量中配置的站点库,并且为了便于查找,我在站点库和普通库中都安装了 magrittr

### Confirming library locations
Sys.getenv("R_LIBS_SITE")
# [1] "C:\\rlib"

.libPaths()
# [1] "C:/rlib"                            "C:/Program Files/R/R-4.0.2/library"

### Confirming `magrittr` is installed
packs = installed.packages()
packs[packs[, "Package"] == "hrbrthemes", c(1, 2, 3)]
#          Package    LibPath                              Version
# magrittr "magrittr" "C:/rlib"                            "1.5"  
# magrittr "magrittr" "C:/Program Files/R/R-4.0.2/library" "1.5"  


### Attempting to install `fnmate`
remotes::install_github("MilesMcBain/fnmate")
# Downloading GitHub repo MilesMcBain/fnmate@HEAD
# √  checking for file 'C:\Users\grego\AppData\Local\Temp\RtmpIx8abP\remotes22d49002b1a\MilesMcBain-fnmate-908f638/DESCRIPTION' ...
# -  preparing 'fnmate':
# √  checking DESCRIPTION meta-information ... 
# -  checking for LF line-endings in source and make files and shell scripts
# -  checking for empty or unneeded directories
# -  building 'fnmate_0.0.1.9000.tar.gz'
#    
# * installing *source* package 'fnmate' ...
# ** using staged installation
# ** R
# ** inst
# ** byte-compile and prepare package for lazy loading
# Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
#   there is no package called 'magrittr'                                                 ##### <<<- see error!
# Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
# Execution halted
# ERROR: lazy loading failed for package 'fnmate'
# * removing 'C:/Program Files/R/R-4.0.2/library/fnmate'
# Error: Failed to install 'fnmate' from GitHub:
#   (converted from warning) installation of package ‘C:/Users/grego/AppData/Local/Temp/RtmpIx8abP/file22d45afbf9f/fnmate_0.0.1.9000.tar.gz’ had non-zero exit status

问题并非这些软件包独有。我接下来尝试安装"hrbrmstr/hrbrthemes",但由于找不到同样安装的extrafont而出错。

所有这些都在 RStudio 的新 R 会话中完成。

奇怪的是,内置 RGui 或 R.exe 中的问题似乎更严重 - 我几乎从不以这种方式运行 R,但它似乎不知道我的任何一个库:

### In RGui
### The environment variable is present, but the lib paths are not updated
> Sys.getenv("R_LIBS_SITE")
[1] "C:\\rlib"

## This path does not exist on my computer
> .libPaths()
[1] "C:/projects/r-base/src/R-source/library"

## the site library is not checked
> library(magrittr)
Error in library(magrittr) : no library trees found in 'lib.loc'

## works if I manually specify the library
library(magrittr, lib.loc = "C:\\rlib")
Warning message:
package 'magrittr' was built under R version 4.0.3

【问题讨论】:

    标签: r package rstudio r-library remotes


    【解决方案1】:

    当我第一次遇到问题时,我仅将站点库指定为环境变量。我试图通过将.Library.site &lt;- "C:/rlib" 行添加到我的Rprofile.site 文件来修复,但没有任何改变——包括RGui 和R.exe 的行为。他们似乎不认识我的网站库,这让我感到惊讶和困惑。

    所以我在我的Rprofile.site 文件(位于Program Files/R/R-4.0.2/etc 中)明确地将站点库添加到.libPaths(),这似乎已经成功了。然后我可以从 RStudio 和从R.exe。

    我的Rprofile.site 文件现在看起来像这样:

    .Library.site <- "C:/rlib"
    .libPaths(.Library.site)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 2021-01-21
      • 2016-11-20
      • 2017-04-11
      • 2016-10-01
      • 2019-10-28
      相关资源
      最近更新 更多