【发布时间】:2017-09-26 14:55:16
【问题描述】:
我开发了一个包,想与工作中的同事分享。
我有一个网络驱动器,我在其中创建了如下所示的本地存储库结构:
MyRepo
\__bin
\__windows
\__contrib
\__src
\__contrib
所有文件夹都是空的。
所以我在 Windows 上使用“Build/More/Build source package”菜单使用 RStudio 构建了我的包,该菜单创建了一个 tar.gz 文件。
然后我尝试了:
drat::insertPackage("../myPkg_0.0.0.9000.tar.gz",
repodir = "file://networkdrive/path/to/MyRepo",
action = "prune")
但这给了我一个错误:
Error: Directory file://networkdrive/path/to/MyRepo not found
这很奇怪,因为 file.exists(//networkdrive/path/to/MyRepo) 返回 true。
好的,那我试试:
drat::insertPackage("../myPkg_0.0.0.9000.tar.gz",
repodir = "//networkdrive/path/to/MyRepo",
action = "prune")
如果存储库路径中没有file:,我会收到另一个错误:
tar (child): "//networkdrive/path/to/MyRepo/src/contrib/myPkg_0.0.0.9000.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
/usr/bin/tar: Child returned status 2
/usr/bin/tar: myPkg/DESCRIPTION: Not found in archive
/usr/bin/tar: Exiting with failure status due to previous errors
reading DESCRIPTION for package ‘myPkg’ failed with message:
cannot open the connection
但是当我进入“//networkdrive/path/to/MyRepo/src/contrib”文件夹时,尽管出现错误消息,我肯定可以看到已复制的 myPkg_0.0.0.9000.tar.gz 文件。
谁能帮忙?
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252 LC_NUMERIC=C LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] drat_0.1.2 tools_3.3.3 git2r_0.18.0
【问题讨论】:
-
我认为
file:///需要三个斜线。 -
试过了,没用:(
-
网络驱动器是邪恶的。在工作中,我们使用绝对路径推送源,但通过 http 使用 drat 内容。您可能需要进行一些本地调试——底层命令都很简单(即
file.copy()等),但确保路径正常则更多是本地问题... -
好的,所以我下载了0.1.2版本的源代码。当我不使用
file:时,错误消息由insertPackage.R 中的第103 行生成:write_PACKAGES(pkgdir, type=pkgtype, ...)。当我使用file:时,它在第 57 行快速失败。dir.exists(repodir) 返回 false,因为 R 正在寻找一个路径以“file:”开头的文件,当然它找不到。 -
进步很大。我们现在需要找到 R 对“类似”目录的另一种用途。基本的 R 包 utils 和工具可以解决这个问题,他们可能会做一些路径“过滤”或“调整”。如果你能解决这个问题那就太好了,因为我通常不在 Windows 上。