简体   繁体   中英

Private Bitbucket package dependency in R package

Summary

When creating a package, I can list CRAN dependencies in the Depends list in the DESCRIPTION file. This documentation outlines how to list Bitbucket dependencies, eg. Remotes: bitbucket::sulab/mygene.r@default .

However, I don't know how to do this when authentication is needed to access the repository.

Attempt

I've tried putting the following code into the main packagename.R file. The function contents work fine as a snippet at the top of a standalone script:

.onLoad <- function(libname, pkgname) {
  otherPackageVersion <- "1.0"
  if (suppressWarnings(suppressPackageStartupMessages(require("otherPackageName", quietly = TRUE, character.only = TRUE)))) {
    if (installed.packages()[installed.packages()[,"Package"] == "otherPackageName", "Version"] != otherPackageVersion) {
      remove.packages("otherPackage")
      devtools::install_bitbucket(sprintf("bitbucketUser/otherPackageName@%s", otherPackageVersion), auth_token = Sys.getenv("BITBUCKET_PAT"))
    }
  } else {
    devtools::install_bitbucket(sprintf("bitbucketUser/otherPackageName@%s", otherPackageVersion), auth_token = Sys.getenv("BITBUCKET_PAT"))
  }
}

but R CMD check fails saying it cannot be loaded after hanging for a while:

checking whether package ‘packageName’ can be installed ... ERROR
Installation failed.

Further Detail

The version of devtools I have loaded is 1.12.0.9000 (see this Github thread ) which I installed using devtools::install_github("hadley/devtools#1220") . This allows me to install private Bitbucket R packages using an App Password stored in an environment variable, rather than committing my username/password in plaintext.

直到这个 (使用Bitbucket PAT的拉取请求)合并到devtools包中之前, 是不可能的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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