rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
998 stars 152 forks source link

`renv::restore()` fails to download private GitHub Repositories #1722

Open jyotishkarc opened 11 months ago

jyotishkarc commented 11 months ago

I have a private repository (say, repo-Y) within an organization (say, org-X). I use that in a project that is synced on three places, viz.

Since there are collaborators, we use renv to keep track of all the packages that we are using. I had a previous version of the package/repository installed on my own computer. Now, through a personal access token, I successfully re-installed repo-Y through devtools::install_github('org-X/repo-Y') on my own machine, and of course did a renv::snapshot() after that. I pushed the updated renv.lock file to the remote repository, and pulled from the cluster.

Now, since I wanted to have the latest version of repo-Y there as well, I did a renv::restore(). However, it produced an error very similar to this issue. The inputs and a shortened output is as follows:

> renv::restore()
The following package(s) will be updated:

# CRAN -----------------------------------------------------------------------
- bslib         [0.4.2 -> 0.5.1]
- cachem        [1.0.6 -> 1.0.8]
- codetools     [0.2-18 -> 0.2-19]
.
.
.
- survival      [3.4-0 -> 3.5-7]
- withr         [2.5.0 -> 2.5.1]
- yaml          [2.3.6 -> 2.3.7]

# GitHub ---------------------------------------------------------------------
- repo-Y        [0.0.0.9000 -> org-X/repo-Y@HEAD]
- tinytex       [rstudio/tinytex@HEAD: 60587ad7 -> 8af916a2]

Do you want to proceed? [Y/n]: Y

# Downloading packages -------------------------------------------------------
- Downloading lattice from CRAN ...             OK [file is up to date]
- Downloading MASS from CRAN ...                OK [file is up to date]
- Downloading tinytex from GitHub ...           OK [50.5 Kb in 1.8s]
- Downloading codetools from CRAN ...           OK [file is up to date]
- Downloading repo-Y from GitHub ...            ERROR [curl: (22) The requested URL returned error: 404 ]
Error: error downloading 'https://api.github.com/repos/org-X/repo-Y/tarball/f5b4540804fd46ac24a30636f08fdb9b901ed816' [curl: (22) The requested URL returned error: 404 ]
Traceback (most recent calls last):
8: renv::restore()
7: renv_restore_run_actions(project, diff, current, lockfile, rebuild)
6: retrieve(packages)
5: handler(package, renv_retrieve_impl(package))
4: renv_retrieve_impl(package)
3: renv_retrieve_github(record)
2: renv_retrieve_package(record, url, path)
1: stop(status)

Initially, I suspected that it might be an issue with my Git configuration itself. That's why, I tried devtools::devtools::install_git('git@github.com:org-X/repo-Y.git' and it got installed! But once again, renv::restore() produced the same error as mentioned above.

I request the developers to kindly have a look into this matter. Please let me know if some additional information is required. Thanks a lot.

orderlyquant commented 9 months ago

I was having similar problems and after reading https://github.com/rstudio/renv/issues/1723, ran renv::install("gitcreds"). The "github" issues went away after this. I agree with https://github.com/rstudio/renv/issues/1723 that this should be made more explicit to the user.

kevinushey commented 9 months ago

https://github.com/rstudio/renv/commit/4c247486b19dd6747aceff7e6df6ffde32e3e8ce should make it more clear if / when gitcreds is needed.