在网络驱动器上使用 Drat 时找不到目录
Directory not found when using Drat on a network drive
我开发了一个包,想与工作中的同事分享。
我有一个网络驱动器,我在其中创建了如下所示的本地存储库结构:
MyRepo
\__bin
\__windows
\__contrib
\__src
\__contrib
所有文件夹都是空的。
因此,我使用 "Build/More/Build source package" 菜单在 Windows 上使用 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)
returns 正确。
好的,那我试了:
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
好的,经过一番研究,这是我的结论。
- 做不到
- 这不是 Drat 的错
之所以不起作用,是因为tools::write_PACKAGES
功能在网络驱动器上不起作用。期间.
我手动将我的包复制到网络驱动器上,然后运行 setwd()
到它的位置并执行write_PACKAGES(".", type="source")
,我得到了同样的错误。
因此,为了完成这项工作,我只是将 package.tar.gz 文件留在本地驱动器上,运行 在本地执行 tools::write_PACKAGES
命令,然后将文件移动到网络驱动器。
使用 options(repos = c(MyRepo = "file://networkdrive/path/to/MyRepo/"))
将网络驱动器添加到我的存储库列表有效:RStudio 和 available.packages
找到我的包。
不是很尽如人意,但我认为这是今天唯一的办法。
我知道这已经过时了,但我的同事刚遇到同样的问题并发现了这个 post。我认为问题可能是您的目录名称中缺少尾部斜杠。我已经能够使用 mapped 网络驱动器重现错误。我可以使用 "H:/MyRepo/" 而不是 "H:/MyRepo".
来解决问题
我还没有用 "file://" 格式尝试过,但我想把我的答案包括在内,以防其他人遇到这个问题。
我也遇到了这个问题,今天终于弄明白了。
对我来说,问题不仅限于网络位置,还发生在 C: 驱动器上。根本原因是 tar.exe 的版本用于解压缩包目录中的现有包。在 tools::write_PACKAGES
函数中调用 utils::untar
。
utils::untar 的文档解释说,在 Windows 上,首先尝试外部 tar.exe。果然,我安装了一个带有 Git 的版本,当文件名中有冒号时,该版本与默认参数一起使用时会失败。通过将环境变量 TAR 设置为 "internal".
,我能够强制 utils::untar
使用 tar.exe 的 RBuildTools 版本
drat::insertPackage
现在可以使用了。
我开发了一个包,想与工作中的同事分享。
我有一个网络驱动器,我在其中创建了如下所示的本地存储库结构:
MyRepo
\__bin
\__windows
\__contrib
\__src
\__contrib
所有文件夹都是空的。
因此,我使用 "Build/More/Build source package" 菜单在 Windows 上使用 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)
returns 正确。
好的,那我试了:
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
好的,经过一番研究,这是我的结论。
- 做不到
- 这不是 Drat 的错
之所以不起作用,是因为tools::write_PACKAGES
功能在网络驱动器上不起作用。期间.
我手动将我的包复制到网络驱动器上,然后运行 setwd()
到它的位置并执行write_PACKAGES(".", type="source")
,我得到了同样的错误。
因此,为了完成这项工作,我只是将 package.tar.gz 文件留在本地驱动器上,运行 在本地执行 tools::write_PACKAGES
命令,然后将文件移动到网络驱动器。
使用 options(repos = c(MyRepo = "file://networkdrive/path/to/MyRepo/"))
将网络驱动器添加到我的存储库列表有效:RStudio 和 available.packages
找到我的包。
不是很尽如人意,但我认为这是今天唯一的办法。
我知道这已经过时了,但我的同事刚遇到同样的问题并发现了这个 post。我认为问题可能是您的目录名称中缺少尾部斜杠。我已经能够使用 mapped 网络驱动器重现错误。我可以使用 "H:/MyRepo/" 而不是 "H:/MyRepo".
来解决问题我还没有用 "file://" 格式尝试过,但我想把我的答案包括在内,以防其他人遇到这个问题。
我也遇到了这个问题,今天终于弄明白了。
对我来说,问题不仅限于网络位置,还发生在 C: 驱动器上。根本原因是 tar.exe 的版本用于解压缩包目录中的现有包。在 tools::write_PACKAGES
函数中调用 utils::untar
。
utils::untar 的文档解释说,在 Windows 上,首先尝试外部 tar.exe。果然,我安装了一个带有 Git 的版本,当文件名中有冒号时,该版本与默认参数一起使用时会失败。通过将环境变量 TAR 设置为 "internal".
,我能够强制utils::untar
使用 tar.exe 的 RBuildTools 版本
drat::insertPackage
现在可以使用了。