简体   繁体   English

如何将私有依赖项添加到 R 开发包的 DESCRIPTION 文件?

[英]how do I add private dependency to DESCRIPTION file for R dev package?

I have built a new package (let's call it myNewPackage ) in R, which uses a private package (let's call it privatePackage ) stored in my company's bitbucket repo.我在 R 中构建了一个新包(我们称之为myNewPackage ),它使用存储在我公司的 bitbucket 存储库中的私有包(我们称之为privatePackage )。

Based on some replies I have found on Google (including this ), I have understood that I need to add Remotes: to my package DESCRIPTION file.根据我在 Google 上找到的一些回复(包括这个),我明白我需要添加Remotes:到我的包 DESCRIPTION 文件中。

Here's what I tried:这是我尝试过的:

Remotes: bitbucket::my_company_username/privatePackage
Imports: 
    bigrquery,
    ...
    privatePackage

but when I try to install myNewPackage in Rstudio:但是当我尝试在 Rstudio 中安装myNewPackage时:

install_bitbucket(repo = "my_company_username/myNewPackage@dev_branch", auth_user = my_user, password = my_pwd)

I get the following error:我收到以下错误:

Error: Failed to install 'myNewPackage' from Bitbucket:
cannot open URL 'https://api.bitbucket.org/2.0/repositories/my_company_username/privatePackage/commit/HEAD'

I suspect the issue is caused by the fact that I have not defined my username and password when I type Remotes: in the DESCRIPTION file of myNewPackage , therefore R is trying to access privatePackage repo on Bitbucket but it doesn't have any authorization to do it.我怀疑这个问题是由于我在myNewPackage的 DESCRIPTION 文件中键入Remotes:时没有定义我的用户名和密码,因此 R 试图访问 Bitbucket 上的privatePackage存储库,但它没有任何授权它。 Unfortunately I don't know where I should add them to the code.不幸的是,我不知道应该在哪里将它们添加到代码中。

NOTE: my_user and my_pwd defined in install_bitbucket() above are sufficient to access privatePackage repo.注意:上面install_bitbucket()中定义的my_usermy_pwd足以访问privatePackage存储库。

I solved this by editing the environment variables, following install_bitbucket() reference guide here :我按照此处install_bitbucket()参考指南编辑环境变量解决了这个问题:

Sys.setenv("BITBUCKET_USER" = my_usr)
Sys.setenv("BITBUCKET_PASSWORD" = my_pwd)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM