问题描述
包装开发初学者在这里!
Package development beginner here!
我正试图第一次将某些代码转换为本地R包。我使用 usethis :: create_package()
制作了一个程序包,并使用 devtools :: document()
添加了文档。
I'm trying to turn some code into a local R package for the very first time. I made a package using usethis::create_package()
, added documentation using devtools::document()
.
现在,在玩了一段时间之后,尝试使用 devtools :: install安装最新版本时遇到了以下错误()
:
Now, after playing around with it for a while, I ran into the following error when trying to install the newest version using devtools::install()
:
Error: HTTP error 403.
API rate limit exceeded for [my IP]. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Rate limit remaining: 0/60
Rate limit reset at: 2019-03-18 16:32:05 UTC
To increase your GitHub API rate limit
- Use `usethis::browse_github_pat()` to create a Personal Access Token.
- Use `usethis::edit_r_environ()` and add the token as `GITHUB_PAT`.
如果我使用 devtools,问题 still 存在:install_local( my_folder_name)
。真正令我困惑的是,我试图通过安装位于本地文件夹中的软件包来达到GitHub速率限制。
The problem still exists if I use devtools:install_local("my_folder_name")
. What genuinely confuses me here is that I am hitting a GitHub rate limit by trying to install a package sitting in a local folder.
我在软件包设置中犯了一个错误,还是使用 devtools :: install()
总是涉及到GitHub API?
是否可以进行任何更改以使软件包的安装过程保持本地化,从而避免速率限制问题?
Did I make a mistake in the package setup, or does using devtools::install()
always involve the GitHub API?Is there anything I can change to keep the installation process of my package local and thus avoid the rate limit issue?
编辑:我的说明文件引用了其他软件包:
My DESCRIPTION file refers to other packages:
Depends:
R (>= 3.4.3),
dplyr
Imports:
RMariaDB,
dbplyr,
DBI,
reshape2,
RColorBrewer,
knitr,
kableExtra,
scales,
magrittr,
DT,
formattable,
testthat,
ggplot2,
rmarkdown
推荐答案
似乎默认情况下, devtools :: install()
检查在 Depends
, Imports
和 DESCRIPTION 文件中的> LinkingTo (请参阅devtools参考中的 dependencies = NA
选项的说明手册)。 remotes :: install_local()
也是如此, devtools :: install_local()
链接到该目录。
It seems that by default, devtools::install()
checks for all packages listed as dependencies under Depends
, Imports
and LinkingTo
in the DESCRIPTION
file (see explanation of dependencies = NA
option in devtools reference manual here). This is also true for remotes::install_local()
, which devtools::install_local()
links to.
一个解决方案是显式禁用检查程序包依赖关系:如果使用 devtools :: install( my_local_package,依赖关系= FALSE)
,您不再需要连接到 api.github.com
。当您知道已经安装了必要的依赖项时,这样做很有意义,例如,您正在打包自己的代码时。
A solution to this is to explicitly disable checking package dependencies: If you use devtools::install("my_local_package", dependencies = FALSE)
instead, you no longer need to connect to api.github.com
. Doing this makes sense when you know you already have the necessary dependencies installed, which is the case when you're R-packaging your own code.
(还应注意: devtools :: install()
中的默认选项需要互联网连接才能安装任何软件包,但通过设置 dependencies = FALSE
,也可以离线安装本地软件包!)
(Also worth noting: The default options in devtools::install()
require an internet connection for installation of any packages but by setting dependencies = FALSE
, it's also possible to install a local package offline!)
这篇关于“超出API速率限制”尝试使用devtools :: install()安装本地R软件包时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!