【问题标题】:Packrat bootstrap doesn't find the packrat private libraryPackrat 引导程序找不到 packrat 私有库
【发布时间】:2015-11-18 23:19:49
【问题描述】:

我已经构建了一个 Packrat 项目,其中包含几个安装在 Packrat 私有库中的包。我想获取代码并将其与 Packrat 库一起带到另一个系统。我在其中构建库的系统是从 Rstudio 运行 R 3.2.2 的 Windows 7,而我将其移动到的系统是从命令行运行 R 3.1.2 的 Linux 机器。 Windows 机器上的 Packrat 版本为 0.4.6-1。以下是我所采取的行动的概要:在我运行的 Windows 机器上

> packrat::bundle(include.lib=TRUE)

我将生成的捆绑包移至 Linux 系统,并使用 tar -zxvf packrat_bundle.tar.gz 将其解压缩。然后我进入新解压缩的目录并启动 R。从那里,packrat 自动引导(由于 source("packrat/init.R") packrat 放在 .Rprofile 中)并给出以下输出

    Packrat is not installed in the local library -- attempting to bootstrap an installation...
> Installing packrat into project private library:
- '/home/code/packrat/lib/x86_64-unknown-linux-gnu/3.1.2'
* installing *source* package âpackratâ ...
** package âpackratâ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (packrat)
> Attaching packrat
> Restoring library
Already up to date.
> Packrat bootstrap successfully completed. Entering packrat mode...
Updating system packages ('3.2.2' -> '3.1.2')
Packrat mode on. Using library in directory:
- "/home/code/packrat/lib"
Warning message:
In restore(restart = FALSE) :
  The most recent snapshot was generated using R version 3.2.2

在此之后,.libPaths() 的输出为

> .libPaths()
[1] "/home/code/packrat/lib/x86_64-unknown-linux-gnu/3.1.2"
[2] "/home/code/packrat/lib-ext"
[3] "/home/code/packrat/lib-R"

问题是我在 Windows 机器上创建的库包含在目录/home/code/packrat/lib/x86_64-w64-mingw32/3.2.2 中。因此,我必须将其添加到 .libPaths 以使 packrat 库正常工作。我不介意必须手动更改.libPaths,但我强烈感觉我可能做错了导致问题的事情。

感谢您的帮助!

【问题讨论】:

  • 升级R后,你运行update.packages(checkBuilt = TRUE)了吗?如果没有,试试这个。似乎某处存在版本冲突(Updating system packages ('3.2.2' -> '3.1.2'))。

标签: r packrat


【解决方案1】:

事实证明,我遇到的问题是在尝试将其移至另一个系统之前,我没有 snapshotted packrat。我通过首先运行packrat::snapshot() 解决了这个问题,然后基本上像以前一样继续进行。

我错误地假设通过使用packrat::bundle(include.lib=TRUE),我可以通过这种方式转移我的图书馆。情况并非如此,尤其是当库需要移动到另一个系统并从源代码重建时。快照首先负责源代码重建,然后 packrat 正确引导。

【讨论】:

  • @FrsLry 请编写您自己的新答案,而不是将回复编辑到现有答案中。但是,无论如何,我认为这不能回答问题,所以它不属于这里。
【解决方案2】:

我的回答与问题无关,但我想写在这里,所以也许有人会读到这篇文章并节省很多时间和挫败感。

这个问题发布已经 2 年了。一年前我使用了packrat 包,直到今天我发现它根本无法使用。我尝试安装dplyr,安装 BH 包(依赖项)需要 1 小时。

使用checkpoint 包会更好。您必须指定 1 个函数

checkpoint("your_snapshot_date")

您已准备好分享您的代码作为可重现的示例。安装 dplyr 的时间:3 分钟。

【讨论】:

    猜你喜欢
    • 2016-10-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-24
    • 2023-03-31
    • 1970-01-01
    • 2010-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多