仅下载包的来源和所有依赖项 [英] Only download sources of a package and all dependencies

查看:75
本文介绍了仅下载包的来源和所有依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用install.packages()或其他相关功能来执行以下操作:仅下载指定程序包及其所有依赖项的源文件(即tar.gz文件)进入指定的文件夹(在Windows中).

I am wondering if there's a way to use install.packages() or other related functions to do the following: only download the sources (i.e. tar.gz files) of the specified packages and all their dependencies into a specified folder (on Windows).

执行此操作的一个原因是:说我有一个未启用Internet访问的Linux帐户.为了在Linux机器上安装软件包,我将首先在Windows机器上下载所有需要的源,然后将它们通过ftp下载到Linux机器,然后使用

One reason to do this is: say I have a Linux account that is not enabled for internet access. In order to install the packages on the Linux machine, I would first download all the needed sources on my Windows machine, then ftp them over to the Linux machine, and install them on the Linux machine using

  install.packages('/home/me/R/Packages/blah.tar.gz', repos = NULL)

推荐答案

现在,基本R:package_dependencies()随附的 tools 软件包中提供了更好的选择.有关相关用例,例如,参见@ sebastian-c的答案以及此最近的问题与解答. strong>

There are now better options for this in the tools package that comes with base R: package_dependencies(). See for example, the Answer from @sebastian-c and this recent Q&A for a related use-case.

在utils软件包中有一个未导出的getDependencies()函数.我还没有研究过它是如何工作的,但是将其与@Dirk的Answers结合使用应该可以帮助您实现大部分目标.

There is an unexported getDependencies() function in the utils package. I haven't studied how it works, but combining that with @Dirk's Answer should get you most of the way there.

基本上,看来您的使用方式如下:

Basically though, it appears you use it like:

utils:::getDependencies(pkgs, dependencies, available, lib)

其中,pkgs是要安装的软件包的字符向量,dependencies是所需的依赖项类型(Depends,Enhances等)的字符向量,availableavailable.packages()是用于在其中评估依赖关系的软件包的库位置.

where pkgs is the character vector of packages to install, dependencies is a character vector of types of dependencies (Depends, Enhances etc) that you want, available is the output from available.packages() and lib is the library location for the packages within which dependencies are evaluated.

如果您调试install.packages(),它实际上是在执行getDependencies()步骤,然后@Dirk的download.packages()步骤才真正开始安装任何东西.

If you debug install.packages() it is basically doing the getDependencies() step then @Dirk's download.packages() step before it actually starts installing anything.

这篇关于仅下载包的来源和所有依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆