简体   繁体   English

remotes::install_github 找不到存在的依赖项

[英]remotes::install_github can't find a dependency that is present

Inspired by Miles McBain's drake video , I want to install the fnmate package/RStudio add-in.受 Miles McBain 的drake video启发,我想安装fnmate包/RStudio 插件。 But remotes::install_github insists that I don't have magrittr , when in fact I do.但是remotes::install_github坚持认为我没有magrittr ,而实际上我有。

I use a site library configured in an environment variable, and, to try to make it easy to find I installed magrittr in both my site library and my normal library.我使用在环境变量中配置的站点库,并且为了便于查找,我在站点库和普通库中都安装了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

The issue is not unique to these packages.这个问题并不是这些包独有的。 I next attempted to install "hrbrmstr/hrbrthemes" and it errored because it couldn't find extrafont , which is also installed.我接下来尝试安装"hrbrmstr/hrbrthemes" ,但它出错了,因为它找不到也已安装的extrafont

All of this is done in a fresh R session in RStudio.所有这些都是在 RStudio 的新 R 会话中完成的。

Oddly, the problems seem worse in the built-in RGui or R.exe - I almost never run R this way, but it seems unaware of either of my libraries:奇怪的是,内置 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

When I first encountered the problem, I specified the site library only as an environment variable.刚开始遇到这个问题的时候,我只指定了站点库作为环境变量。 I attempted to fix by adding the line .Library.site <- "C:/rlib" to my Rprofile.site file, but nothing changed - including the behavior of RGui and R.exe.我试图通过将.Library.site <- "C:/rlib"行添加到我的Rprofile.site文件来修复,但没有任何改变 - 包括 RGui 和 R.exe 的行为。 I was surprised and confused that they don't seem to recognize my site library.我很惊讶也很困惑,他们似乎不认识我的网站库。

So I explicitly added the site library to .libPaths() in my Rprofile.site file (located in Program Files/R/R-4.0.2/etc , and that seems to have done the trick. I was then able to use remotes::install_github both from RStudio and from R.exe.所以我明确地将该网站添加库.libPaths()在我的Rprofile.site (位于文件Program Files/R/R-4.0.2/etc ,这似乎已经完成了帽子戏法。当时我能够用remotes::install_github来自 RStudio 和 R.exe。

My Rprofile.site file now looks like this:我的Rprofile.site文件现在看起来像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM