rbitbucketr-packageremotes

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.

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.

Here's what I tried:

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

but when I try to install myNewPackage in Rstudio:

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. 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.


Solution

  • I solved this by editing the environment variables, following install_bitbucket() reference guide here:

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