Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R packrat快照:升级包提供;陈腐的;错误_R_Package_Packrat - Fatal编程技术网

R packrat快照:升级包提供;陈腐的;错误

R packrat快照:升级包提供;陈腐的;错误,r,package,packrat,R,Package,Packrat,我正在使用冻结应用程序依赖项的所有版本。有时我会遇到“陈腐”的麻烦 例如,今天我将一个软件包升级到了一个新版本。为此,我在packrat管理的项目中启动了R: % R --quiet Packrat mode on. Using library in directory: - "~/git/myapp/app/packrat/lib" > install.packages('MyPackage') Installing package into ‘/Users/kwilliams/git/

我正在使用冻结应用程序依赖项的所有版本。有时我会遇到“陈腐”的麻烦

例如,今天我将一个软件包升级到了一个新版本。为此,我在
packrat
管理的项目中启动了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.
% git diff
diff --git a/app/packrat/packrat.lock b/app/packrat/packrat.lock
index 6c17020..f717d29 100644
--- a/app/packrat/packrat.lock
+++ b/app/packrat/packrat.lock
@@ -30,9 +30,9 @@ Hash: 9772da3bc51603a19a2b75f008fd63e3

 Package: MyPackage
 Source: source
-Version: 7.3.1-22287
+Version: 7.4
 SourcePath: lib/MyPackage
-Hash: 4fe20417f5711b3c7c90a4efe3bb4bc7
+Hash: 880a308537e8de571106893e839386f6
...
我想我会强制它,所以我添加了
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
bug:

  • 无法快照新安装的包
  • 无法下载包的源代码

  • FWIW,我认为第一个问题与这里的情况相同:,Kevin Ushey(packrat
    的作者/维护者)说,“有可能‘过时’软件包的逻辑会消失。”

    以下是我用来重新上路的变通方法:

  • 如上所述,使用
    ignore.stale=TRUE
    强制快照,即使它认为事情已经过时

  • 手动将源程序包复制到
    packrat/src/MyPackage/

  • 现在它成功了:

    > packrat::snapshot(ignore.stale=TRUE)
    
    Upgrading these packages already present in packrat:
                           from    to
        MyPackage   7.3.1-22287   7.4
    
    Snapshot written to '/Users/kwilliams/git/myapp/app/packrat/packrat.lock'
    
    packrat/packrat.lock
    文件已正确更新:

    > 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.
    
    % git diff
    diff --git a/app/packrat/packrat.lock b/app/packrat/packrat.lock
    index 6c17020..f717d29 100644
    --- a/app/packrat/packrat.lock
    +++ b/app/packrat/packrat.lock
    @@ -30,9 +30,9 @@ Hash: 9772da3bc51603a19a2b75f008fd63e3
    
     Package: MyPackage
     Source: source
    -Version: 7.3.1-22287
    +Version: 7.4
     SourcePath: lib/MyPackage
    -Hash: 4fe20417f5711b3c7c90a4efe3bb4bc7
    +Hash: 880a308537e8de571106893e839386f6
    ...
    

    以下是我用来重新上路的变通方法:

  • 如上所述,使用
    ignore.stale=TRUE
    强制快照,即使它认为事情已经过时

  • 手动将源程序包复制到
    packrat/src/MyPackage/

  • 现在它成功了:

    > packrat::snapshot(ignore.stale=TRUE)
    
    Upgrading these packages already present in packrat:
                           from    to
        MyPackage   7.3.1-22287   7.4
    
    Snapshot written to '/Users/kwilliams/git/myapp/app/packrat/packrat.lock'
    
    packrat/packrat.lock
    文件已正确更新:

    > 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.
    
    % git diff
    diff --git a/app/packrat/packrat.lock b/app/packrat/packrat.lock
    index 6c17020..f717d29 100644
    --- a/app/packrat/packrat.lock
    +++ b/app/packrat/packrat.lock
    @@ -30,9 +30,9 @@ Hash: 9772da3bc51603a19a2b75f008fd63e3
    
     Package: MyPackage
     Source: source
    -Version: 7.3.1-22287
    +Version: 7.4
     SourcePath: lib/MyPackage
    -Hash: 4fe20417f5711b3c7c90a4efe3bb4bc7
    +Hash: 880a308537e8de571106893e839386f6
    ...
    

    手动复制源代码似乎在玩火。更谨慎的解决方案是将源代码复制到本地repo,并使用
    packrat::set_opts(local.repos=“”)
    (“安装本地源代码包”一节)。我有兴趣将安装问题与快照问题分开。如果使用
    ignore.stale=TRUE
    但不将新包源代码复制到packrat目录中会发生什么情况?手动复制源代码似乎是在玩火。更谨慎的解决方案是将源代码复制到本地repo,并使用
    packrat::set_opts(local.repos=“”)
    (“安装本地源代码包”一节)。我有兴趣将安装问题与快照问题分开。如果使用
    ignore.stale=TRUE
    但不将新包源复制到packrat目录,会发生什么情况?