我packrat
用来冻结应用程序的所有版本的依赖项。有时我会遇到“陈旧”的麻烦。
例如,今天我将一个软件包升级到了较新的版本。我通过在packrat
-managed 项目中启动 R 来做到这一点:
% R --quiet
Packrat mode on. Using library in directory:
- "~/git/myapp/app/packrat/lib"
> install.packages('MyPackage')
Installing package into ‘/Users/kwilliams/git/myapp/app/packrat/lib/x86_64-apple-darwin17.7.0/3.5.3’
(as ‘lib’ is unspecified)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3537k 100 3537k 0 0 5530k 0 --:--:-- --:--:-- --:--:-- 5527k
* installing *source* package ‘MyPackage’ ...
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (MyPackage)
The downloaded source packages are in
‘/private/var/folders/zp/hj5hqfw970z0_78mrb_802lm0001z9/T/RtmpzfYDUz/downloaded_packages’
但是,当我尝试生成新的快照文件时,什么也没有发生:
> packrat::snapshot()
Snapshot written to '/Users/kwilliams/git/myapp/app/packrat/packrat.lock'
(该文件与以前没有什么不同 -MyPackage
仍然列出旧版本。)
我确认确实安装了新版本,然后再次尝试快照:
> packageVersion('MyPackage')
[1] ‘7.4’
> packrat::snapshot()
The following packages are stale:
_
MyPackage 7.4
These packages must be updated by calling packrat::restore() before
snapshotting. If you are sure you want the installed versions of these
packages to be snapshotted, call packrat::snapshot() again with
ignore.stale=TRUE.
--
Snapshot operation was cancelled, no changes were made.
嗯?不知道为什么两次之间的结果不同。
status()
似乎确实正确地了解了情况:
> packrat::status()
The following packages are out of sync between packrat and your current library:
packrat library
MyPackage 7.3.1-22287 7.4
Use packrat::snapshot() to set packrat to use the current library, or use
packrat::restore() to reset the library to the last snapshot.
我想我会强迫它,所以我补充说ignore.stale=TRUE
:
> packrat::snapshot(ignore.stale=TRUE)
Upgrading these packages already present in packrat:
from to
MyPackage 7.3.1-22287 7.4
Fetching sources for MyPackage (7.4) ... FAILED
Error in snapshotSources(project, activeRepos(project), allRecordsFlat) :
Errors occurred when fetching source files:
Error in getSourceForPkgRecord(pkgRecord, sourceDir, availablePkgs, repos) :
Could not find sources for MyPackage (7.4).
真可惜。这可能与这是一个本地创建的包,从类似本地 CRAN 安装的事实有关吗?这将是一个packrat
错误,因为(如上所述)install.packages()
可以很好地找到源包。
所以我认为这里有两个潜在的packrat
错误:
- 无法对新安装的软件包进行快照
- 无法下载软件包的源代码
FWIW,我认为第一个问题与这里的情况相同:https : //groups.google.com/forum/#!topic/packrat-discuss/HvD45u6w4Zg,其中 Kevin Ushey(作者/维护者packrat
)说“有可能围绕“陈旧”包装的逻辑可以消失。”