RStudio can't access Package Manager URL but I can with a browser

We recently started using renv, which automatically switched our package repo to Package Manager. This created an issue because for some reason RStudio can't access it when trying to install packages:

Warning: unable to access index for repository https://packagemanager.posit.co/cran/latest/src/contrib:
  cannot open URL 'https://packagemanager.posit.co/cran/latest/src/contrib/PACKAGES

I can open this URL via a browser with no problem as well as with httr2:

<httr2_response>
GET https://packagemanager.posit.co/cran/latest/src/contrib/PACKAGES
Status: 200 OK
Content-Type: text/plain
Body: In memory (4533467 bytes)

I don't have a problem downloading packages through CRAN, just with Package Manager. Would we expect it to fail using httr2 if it's failing to access the URL when downloading a package? Any thoughts on how I can troubleshoot this issue?

Hi @jonbry, the difference here might be the download method used by renv vs. httr. So a couple questions to try and troubleshoot this:

  • Do you have a proxy in this environment where access to https://packagemanager.posit.co would fail if the proxy was not being used?
  • What is the download method configured as in R, which is what renv would be using? In R, what is the output of:
options("download.file.method", "download.file.extra")
  • If you haven't customized the download method in R, what do you get when you enable verbose debug logging and try to access that same URL with R's default download method:
options(internet.info = 1)
curlGetHeaders("https://packagemanager.posit.co/cran/latest/src/contrib/PACKAGES")