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 afp.data
which I've specified in the Remotes
section of the package DESCRIPTION file as:
Remotes:
bitbucket::myorg/afp.data@v0.2.2
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 'https://api.bitbucket.org/2.0/repositories/myorg/afp.data/src/v0.2.2/DESCRIPTION'
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!
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
Hi Patrik, thanks for your reply! I just created an app password and gave it the following permissions. Now it says:
```
cannot open URL 'https://api.bitbucket.org/2.0/repositories/myorg/afp.data/commit/v0.2.2'
```.
The error message seems a bit different but I'm not sure if it's relevant...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 (afp.data), 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.