r-lib / remotes

Install R packages from GitHub, GitLab, Bitbucket, git, svn repositories, URLs
https://remotes.r-lib.org/
Other
323 stars 152 forks source link

install_bitbucket from private host: hardcoded directory "repositories" in URL #584

Open andreagrioni opened 3 years ago

andreagrioni commented 3 years ago

I have a R package on a private BitBucket server.

The cmd remotes::install_bitbucket(repo="user/repo.git", host="bitbucket.NAME.net/") exited with error message:

Error: Failed to install 'unknown package' from Bitbucket: cannot open URL 'https://bitbucket.NAME.net//repositories/user/repo.git/src/HEAD/DESCRIPTION'

Note that the directory repositories is not provided in the arguments but it is hardcoded by the install_bitbucket function.

lmullany commented 3 years ago

Same issue with me.. When I override with my private bitbucket server, the hardcoding of repositories within the construction of the url causes this to fail

See: https://github.com/r-lib/remotes/issues/429

aprijol commented 3 years ago

Also having this issue!

lmullany commented 2 years ago

@andreagrioni and/or @aprijol : Have either of you found a good work around for this?

gaborcsardi commented 2 years ago

What is the correct URL on a private server?

robertkck commented 2 years ago

Our Bitbucket Server can be addressed with the Bitbucket Server REST API, but I am not able to identify the right requests to change the install_bitbucket function. Happy to assist if possible.

gaborcsardi commented 2 years ago

Well, I don't have access to any private BitBucket repos, but if you can create a PR, I'll be happy to review it.

lmullany commented 2 years ago

What is the correct URL on a private server?

@gaborcsardi , I'm sorry to say that I'm not sure.. I don't know if this example helps or not:

The remote is this: https://code.jh.edu/scm/psq/pmaputilities.git

In a browser, I can directly access the repos like this.. https://code.jh.edu/projects/PSQ/repos/pmaputilities/browse

I have an auth token and thought I would be able to install the package like this:

auth_token = <my token>
remotes::install_bitbucket(
    repo = "repos/pmapUtilities",
    ref="main",
    host="code.jh.edu/projects/psq/",
    upgrade="never",
    auth_token = auth_token
    )

output:

Error: Failed to install 'unknown package' from Bitbucket:
  cannot open URL 'https://code.jh.edu/projects/psq//repositories/repos/pmapUtilities/src/main/DESCRIPTION'
Traceback:

1. remotes::install_bitbucket(repo = "repos/pmapUtilities", ref = "main", 
 .     host = "code.jh.edu/projects/psq/", upgrade = "never", auth_token = auth_token)
2. install_remotes(remotes, auth_user = auth_user, password = password, 
 .     host = host, dependencies = dependencies, upgrade = upgrade, 
 .     force = force, quiet = quiet, build = build, build_opts = build_opts, 
 .     build_manual = build_manual, build_vignettes = build_vignettes, 
 .     repos = repos, type = type, ...)
3. tryCatch(res[[i]] <- install_remote(remotes[[i]], ...), error = function(e) {
 .     stop(remote_install_error(remotes[[i]], e))
 . })
4. tryCatchList(expr, classes, parentenv, handlers)
5. tryCatchOne(expr, names, parentenv, handlers[[1L]])
6. value[[3L]](cond)

I notice the hard coding of the term "repositories" as also experienced by @andreagrioni . I may be doing a number of other things incorrectly -- any insight you can provide would be much appreciated... or any workaround!

aprijol commented 2 years ago

What is the correct URL on a private server?

Private servers can have a number of things in that node. Our organization has the org abbreviation there. I just went in and removed "repositories" from the build_url calls. I added the node I needed to username (e.g., orgabbrev/username). I still had issues further down the line with authentication and ended up having to put this effort on hold. But, just taking out "repositories" worked for this issue.

morriso1 commented 2 years ago

I also have this problem. Is there any way we can specify the whole URL? This would be a great feature as the current hard coding of "repositories" does not work for me

andysw90 commented 7 months ago

Any potential workarounds to this? I am having the same issue

gaborcsardi commented 7 months ago

You could try the git:: syntax of pak: https://r-lib.github.io/pkgdepends/reference/pkg_refs.html#packages-in-git-repositories-git-