Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Installing an R package in a Docker image that has a dependency on another Bitbucket package

Charith Wijewardena May 9, 2023

I'm trying to install a Bitbucket R package in a Docker image. The command to do this in my Dockerfile is:

RUN --mount=type=secret,id=bitbucket_password . /run/secrets/bitbucket_password && R -e "remotes::install_bitbucket(repo='myorg/afp.model',ref='v0.1.1',auth_user='$BITBUCKET_USER',password='$BITBUCKET_PASSWORD')"

The problem is this package has a dependency on another of our R packages which I've specified in the Remotes section of the package DESCRIPTION file as:


When I try to build the package I get the following error at the terminal:

Error: Failed to install 'afp.model' from Bitbucket:
  cannot open URL ''

I've already passed in my username and password, and I am able to install our other packages that don't have such dependencies, so I'm not sure why it can't open that URL (if it's a permissions issue)?

Installing this package on my local desktop works fine, it's just in the Docker image that's the problem.

Would appreciate any help in troubleshooting this! 

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 11, 2023

Hello @Charith Wijewardena ,

Welcome to the Community!

From the description you have shared, I suspect the issue is related to authentication.

When trying to install the afp.model package, your application is using the Bitbucket Cloud API (the URL that appears on the logs), and you mentioned to have configured the authentication as your username and password. However, when using basic authentication for API calls you will need to provide the bitbucket username and an app password.

The app password is different from the password you use to login in the UI, and is used to authenticate git commands and also API calls.

With that in mind, could you try to create an app password under your bitbucket account and use it along with your bitbucket username as the credentials for authentication in your Dockerfile? 

Let me know in case you have any questions.

Thank you, @Charith Wijewardena !

Patrik S

Charith Wijewardena May 14, 2023

Hi Patrik, thanks for your reply! I just created an app password and gave it the following permissions. Now it says:


cannot open URL ''


The error message seems a bit different but I'm not sure if it's relevant...

Screenshot 2023-05-15 110516.png

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 15, 2023

Hello @Charith Wijewardena ,

Thank you for sharing the results of the testing.

I suspect that R is not propagating the credentials for authenticating the request to download the dependency of your dependency (, which is causing the error you reported.

I would suggest trying to provide the credentials as environment variables as per what is described in R's install Bitbucket documentation. You would need to create an env variable BITBUCKET_USER with the value of your bitbucket user, and BITBUCKET_PASSWORD with the app password you have created. Maybe with the credentials set on the environment level, they will be propagated when trying to download the nested dependency.

If that still does not work, I would suggest reporting this issue on r-libs issue tracker.

Thank you, @Charith Wijewardena !

Patrik S

Charith Wijewardena May 15, 2023

Thanks Patrik, it didn't work either so I'll raise an issue or try to work around our dependencies so we don't get that problem.

Like Patrik S likes this

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events