r-lib / remotes

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

Unable to install package with private Git remotes #795

Closed jkeirstead closed 6 months ago

jkeirstead commented 6 months ago

I'm developing a package using renv and it depends on other packages in private Github repositories. These are accessed via SSH and installed with renv::install('git@github.com:myorg/mypkg.git'). While this works fine for development purposes, the package will not install (e.g. devtools::install()) and fails with the following message:

Error in FUN(X[[i]], ...) : 
  can't convert package mypkg with RemoteType 'git' to remote

Here's a traceback:

d> traceback()
8: stop(sprintf("can't convert package %s with RemoteType '%s' to remote", 
       name, x$RemoteType)) at install-remote.R#230
7: FUN(X[[i]], ...)
6: lapply(deps, package2remote, repos = repos, type = type) at deps.R#76
5: structure(lapply(deps, package2remote, repos = repos, type = type), 
       class = "remotes") at deps.R#76
4: package_deps(deps, repos = repos, type = type) at deps.R#141
3: dev_package_deps(pkgdir, repos = repos, dependencies = dependencies, 
       type = type) at install.R#191
2: remotes::install_deps(pkg$path, build = build, build_opts = build_opts, 
       INSTALL_opts = opts, dependencies = dependencies, quiet = quiet, 
       force = force, upgrade = upgrade, ...)
1: install()

the relevant parts of the session info:

─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.0.3 (2020-10-10)
 os       macOS  14.4.1
 system   x86_64, darwin17.0
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Berlin
 date     2024-05-14
 rstudio  2024.04.0+735 Chocolate Cosmos (desktop)
 pandoc   3.1.11 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/x86_64/ (via rmarkdown)
─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 !  package                * version    date (UTC) lib source
 P  mypkg                 0.2.2      2022-11-09 [?] git (git@github.com:myorg/mypkg.git)
 P  devtools               * 2.4.5      2022-10-11 [?] CRAN (R 4.0.3)
 P  remotes                  2.5.0      2024-03-17 [?] CRAN (R 4.0.3)
    renv                     1.0.7      2024-04-11 [2] CRAN (R 4.0.3)

and the relevant bits of the DESCRIPTION file for the package that's being developed:

Imports: mypkg
Remotes: git::git@github.com:myorg/mypkg.git

Any idea how to resolve this?

gaborcsardi commented 6 months ago

Can you try using r-lib/pak instead of remotes? It will require you to use a https git remote though.

jkeirstead commented 6 months ago

If possible, I want to avoid using https git remotes as it would require changes in the rest of my build environment. Is there no fix for using SSH remotes?

gaborcsardi commented 6 months ago

IDK, it does not fail for me for private repos:

❯ remotes::install_git("git@github.com:gaborcsardi/playground2.git")
Downloading git repo git@github.com:gaborcsardi/playground2.git
'/opt/homebrew/bin/git' clone --depth 1 --no-hardlinks git@github.com:gaborcsardi/playground2.git /var/folders/ph/fpcmzfd16rgbbk8mxvy9m2_h0000gn/T//RtmpWQCCcU/file1018522ed21ec
Cloning into '/var/folders/ph/fpcmzfd16rgbbk8mxvy9m2_h0000gn/T//RtmpWQCCcU/file1018522ed21ec'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 0), reused 6 (delta 0), pack-reused 0
Receiving objects: 100% (7/7), done.
jkeirstead commented 6 months ago

remotes::install_git works for me too. It seems to be something with converting the dependency to the right install_ call (see the traceback above)

jkeirstead commented 6 months ago

An update on this: converting to https git remotes solves the problem without having to switch to pak.