You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this is the overall issue similar to #701 and the same issue as #697.
Description: If you pass in auth_token to install_github and don't have GITHUB_PAT set (so that remotes:::github_pat() returns NULL), you will get a failure. Let's say we have pkgA (private repo, muschellij2/pkgA) and pkgB (private repo, muschellij2/pkgB), that depends on pkgA and has pkgA set in the Remotes field.
Below, I have a reprex that demonstrates the issue, but the issue is that the packages are private (which is the overall issue). I'm happy to make an r-lib maintainer to make things easier. I also created a video demonstrating the issue: https://youtu.be/qZi_50QojbM.
Issue: Expected behavior is that if auth_token is passed to install_github, then GITHUB_PAT does not need to be set. The issue is that auth_token doesn't get passed to the dependency remotes. The failure happens at remote_sha, and package2remote (as package2remote uses remotes:::github_pat() for the auth_token parameter).
Solution: If you have private dependencies, you must set GITHUB_PAT for this to work. The auth_token will not pass through.
Reprex
GITHUB_PAT is in object auth_token - done outside of reprex (deleted line)
nchar(auth_token)
#> [1] 40
Demonstration of the issue
Overall, things are fine if GITHUB_PAT or GITHUB_TOKEN are set as environment variables, because remotes::github_pat will pick them up. In our case, we see they are not set:
Try to install package - fails because pkgA is private
remotes::install_github("muschellij2/pkgA")
#> Error: Failed to install 'unknown package' from GitHub:#> HTTP error 404.#> Not Found#> #> Did you spell the repo owner (`muschellij2`) and repo name (`pkgA`) correctly?#> - If spelling is correct, check that you have the required permissions to access the repo.
Pass in auth_token directly - succeeds
remotes::install_github("muschellij2/pkgA", auth_token=auth_token)
#> Downloading GitHub repo muschellij2/pkgA@HEAD#> * checking for file ‘/tmp/RtmpzJUpNR/remotes1acb477ff0ad/muschellij2-pkgA-9d94302887cda58639c76f1e06ffc3664e29138d/DESCRIPTION’ ... OK#> * preparing ‘pkgA’:#> * checking DESCRIPTION meta-information ... OK#> * checking for LF line-endings in source and make files and shell scripts#> * checking for empty or unneeded directories#> * building ‘pkgA_0.0.0.9000.tar.gz’#> Installing package into '/home/gcer/R'#> (as 'lib' is unspecified)
Following fails because pkgA is private and auth_token passed. But note that it says Failed to install 'pkgB' from GitHub:
remotes::install_github("muschellij2/pkgB", auth_token=auth_token)
#> Downloading GitHub repo muschellij2/pkgB@HEAD#> Error: Failed to install 'pkgB' from GitHub:#> HTTP error 404.#> Not Found#> #> Did you spell the repo owner (`muschellij2`) and repo name (`pkgA`) correctly?#> - If spelling is correct, check that you have the required permissions to access the repo.
Issue resolved if GITHUB_PAT is set
Here we will set GITHUB_PAT, show remotes:::github_pat picks it up, and install_github works fine.
The installation succeeds below because it is using GITHUB_PAT for both auth_token (initial package call) and when remotes:::github_pat() called in dependency.
remotes::install_github("muschellij2/pkgB")
#> Using github PAT from envvar GITHUB_PAT. Use `gitcreds::gitcreds_set()` and unset GITHUB_PAT in .Renviron (or elsewhere) if you want to use the more secure git credential store instead.#> Downloading GitHub repo muschellij2/pkgB@HEAD#> #> * checking for file ‘/tmp/RtmpzJUpNR/remotes1acb60a90f49/muschellij2-pkgB-c3b57cff32842cd365e1d5582f981648a28e7705/DESCRIPTION’ ... OK#> * preparing ‘pkgB’:#> * checking DESCRIPTION meta-information ... OK#> * checking for LF line-endings in source and make files and shell scripts#> * checking for empty or unneeded directories#> * building ‘pkgB_0.0.0.9000.tar.gz’#> Installing package into '/home/gcer/R'#> (as 'lib' is unspecified)
remove.packages("pkgB")
#> Removing package from '/home/gcer/R'#> (as 'lib' is unspecified)
This includes succeeding when auth_token is passed (auth_token used for pkgB, remotes:::github_pat used for pkgA and all dependencies:
remotes::install_github("muschellij2/pkgB", auth_token=auth_token)
#> Downloading GitHub repo muschellij2/pkgB@HEAD#> #> * checking for file ‘/tmp/RtmpzJUpNR/remotes1acb2efeb5e2/muschellij2-pkgB-c3b57cff32842cd365e1d5582f981648a28e7705/DESCRIPTION’ ... OK#> * preparing ‘pkgB’:#> * checking DESCRIPTION meta-information ... OK#> * checking for LF line-endings in source and make files and shell scripts#> * checking for empty or unneeded directories#> * building ‘pkgB_0.0.0.9000.tar.gz’#> Installing package into '/home/gcer/R'#> (as 'lib' is unspecified)
remove.packages("pkgB")
#> Removing package from '/home/gcer/R'#> (as 'lib' is unspecified)
Sys.unsetenv("GITHUB_PAT")
Demonstrating it is GITHUB_PAT
Here can can pass in garbage to GITHUB_PAT to demonstrate the main repo (pkgB) is using auth_token by getting information. Note below says Failed to install 'pkgB' from GitHub:
Sys.setenv(GITHUB_PAT="asdlfkjas;dfja")
remotes::install_github("muschellij2/pkgB", auth_token=auth_token)
#> Downloading GitHub repo muschellij2/pkgB@HEAD#> Error: Failed to install 'pkgB' from GitHub:#> HTTP error 401.#> Bad credentials#> #> Rate limit remaining: 53/60#> Rate limit reset at: 2023-06-02 19:06:18 UTC#> #>
remove.packages("pkgB")
#> Removing package from '/home/gcer/R'#> (as 'lib' is unspecified)#> Error in find.package(pkgs, lib): there is no package called 'pkgB'
Sys.unsetenv("GITHUB_PAT")
Here can can pass in garbage to auth_token to show that it fails at the point of reading the main package, such that it is not using GITHUB_PAT for the main repo read. Note unknown package vs. pkgB above:
Sys.getenv("GITHUB_PAT")
#> [1] ""
Sys.setenv(GITHUB_PAT=auth_token)
remotes::install_github("muschellij2/pkgB", auth_token="asdfdsf")
#> Error: Failed to install 'unknown package' from GitHub:#> HTTP error 401.#> Bad credentials#> #> Rate limit remaining: 52/60#> Rate limit reset at: 2023-06-02 19:06:18 UTC#> #>
remove.packages("pkgB")
#> Removing package from '/home/gcer/R'#> (as 'lib' is unspecified)#> Error in find.package(pkgs, lib): there is no package called 'pkgB'
Sys.unsetenv("GITHUB_PAT")
Where the problem occurs
The issue occurs in dev_package_deps. In order to use dev_package_deps locally, we need to clone the package, and need to set GITHUB_PAT for git2r::cred_token:
Pulling package deps succeeds because GITHUB_PAT set
r=remotes::dev_package_deps(pkgdir=pkgdir)
But dev_package_deps fails after we unset GITHUB_PAT
Sys.unsetenv("GITHUB_PAT")
remotes::dev_package_deps(pkgdir=pkgdir)
#> Error: HTTP error 404.#> Not Found#> #> Did you spell the repo owner (`muschellij2`) and repo name (`pkgA`) correctly?#> - If spelling is correct, check that you have the required permissions to access the repo.
Digging into dev_package_deps
Code extracted from dev_package_deps:
# setting up vars like defaults in `dev_package_deps`repos= getOption("repos")
dependencies=NAtype= getOption("pkgType")
pkg<-remotes:::load_pkg_description(pkgdir)
repos<- c(repos, remotes:::parse_additional_repositories(pkg))
deps<-remotes:::local_package_deps(pkgdir=pkgdir, dependencies=dependencies)
deps#> [1] "pkgA"
In dev_package_deps, the code fails at package_deps (
cran_deps<-remotes:::package_deps(deps, repos=repos, type=type)
#> Error: HTTP error 404.#> Not Found#> #> Did you spell the repo owner (`muschellij2`) and repo name (`pkgA`) correctly?#> - If spelling is correct, check that you have the required permissions to access the repo.
Digging into remotes:::package_deps
The variables change names a bit, but we pass deps into the packages argument for remotes:::package_deps
I think this is the overall issue similar to #701 and the same issue as #697.
Description: If you pass in
auth_token
toinstall_github
and don't have GITHUB_PAT set (so thatremotes:::github_pat()
returnsNULL
), you will get a failure. Let's say we have pkgA (private repo,muschellij2/pkgA
) and pkgB (private repo,muschellij2/pkgB
), that depends on pkgA and has pkgA set in theRemotes
field.Below, I have a
reprex
that demonstrates the issue, but the issue is that the packages are private (which is the overall issue). I'm happy to make anr-lib
maintainer to make things easier. I also created a video demonstrating the issue: https://youtu.be/qZi_50QojbM.Issue: Expected behavior is that if
auth_token
is passed toinstall_github
, thenGITHUB_PAT
does not need to be set. The issue is thatauth_token
doesn't get passed to the dependency remotes. The failure happens atremote_sha
, andpackage2remote
(aspackage2remote
usesremotes:::github_pat()
for theauth_token
parameter).Solution: If you have private dependencies, you must set
GITHUB_PAT
for this to work. Theauth_token
will not pass through.Reprex
GITHUB_PAT
is in objectauth_token
- done outside of reprex (deleted line)Demonstration of the issue
Overall, things are fine if
GITHUB_PAT
orGITHUB_TOKEN
are set as environment variables, becauseremotes::github_pat
will pick them up. In our case, we see they are not set:Try to install package - fails because
pkgA
is privatePass in
auth_token
directly - succeedsFollowing fails because
pkgA
is private andauth_token
passed. But note that it saysFailed to install 'pkgB' from GitHub:
Issue resolved if
GITHUB_PAT
is setHere we will set
GITHUB_PAT
, showremotes:::github_pat
picks it up, andinstall_github
works fine.The installation succeeds below because it is using
GITHUB_PAT
for bothauth_token
(initial package call) and whenremotes:::github_pat()
called in dependency.This includes succeeding when
auth_token
is passed (auth_token
used forpkgB
,remotes:::github_pat
used forpkgA
and all dependencies:Demonstrating it is
GITHUB_PAT
Here can can pass in garbage to
GITHUB_PAT
to demonstrate the main repo (pkgB
) is usingauth_token
by getting information. Note below saysFailed to install 'pkgB' from GitHub:
Here can can pass in garbage to
auth_token
to show that it fails at the point of reading the main package, such that it is not usingGITHUB_PAT
for the main repo read. Noteunknown package
vs.pkgB
above:Where the problem occurs
The issue occurs in
dev_package_deps
. In order to usedev_package_deps
locally, we need to clone the package, and need to setGITHUB_PAT
forgit2r::cred_token
:We can see that it does work:
Pulling package deps succeeds because
GITHUB_PAT
setBut
dev_package_deps
fails after we unsetGITHUB_PAT
Digging into
dev_package_deps
Code extracted from
dev_package_deps
:In
dev_package_deps
, the code fails atpackage_deps
(remotes/R/deps.R
Line 143 in e199c1b
Digging into
remotes:::package_deps
The variables change names a bit, but we pass
deps
into thepackages
argument forremotes:::package_deps
Here, we see no
auth_token
is passed aspackage2remote
usesgithub_pat
:remotes/R/install-remote.R
Line 241 in e199c1b
Without
GITHUB_PAT
set, we do not get the auth needed:And setting
GITHUB_PAT
, it gets correctly passed toremote
:Created on 2023-06-02 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: