Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot download from behind proxy #735

Open
Luke-Symes-Tsy opened this issue Jan 12, 2025 · 2 comments
Open

Cannot download from behind proxy #735

Luke-Symes-Tsy opened this issue Jan 12, 2025 · 2 comments

Comments

@Luke-Symes-Tsy
Copy link

Luke-Symes-Tsy commented Jan 12, 2025

My Windows computer, with R 4.4.2, uses a proxy to access the internet.

Using options(download.file.method = "wininet"), I can successfully run install.packages("zip"). However, running pak::pkg_install("zip") fails with:

Error: 
! error in pak subprocess
Caused by error in `download.file(url, tmp, quiet = TRUE)`:
! cannot open URL 'http://bioconductor.org/config.yaml'

For example:
image

It seems like pak is not recognising the download.file.method option? I am using pak 0.8.0 from CRAN.

@gaborcsardi
Copy link
Member

pak does not use download.file() and does not use download.file.method. This is a bug that is possibly fixed in the devel version, you can install it like this:
https://pak.r-lib.org/reference/install.html#nightly-builds

@Luke-Symes-Tsy
Copy link
Author

Luke-Symes-Tsy commented Jan 21, 2025

I tracked down the issue to pkgcache trying to update the Bioconductor metadata. pkgcache essentially calls pkgcache:::bioconductor$.internal$read_url("http://bioconductor.org/config.yaml") which uses download.file.

However, the issue seems to be that pak does not tell callr (which runs pkgcache etc) to use the user's .Rprofile - it defaults to user_profile = "project" which looks for a project-specific .Rprofile:

user_profile = if (Sys.getenv("RENV_PROJECT") != "") FALSE else "project"

If I create a project-specific .Rprofile with the right options, then pak::pkg_install("zip") works (after a session restart):

Sys.setenv(ALL_PROXY = ":@<proxy_url>:<proxy_port>")
options(download.file.method = "curl")

What I think should be happening, is if a project-specific .Rprofile does not exist, we should default to user_profile = TRUE which tells callr to use R_PROFILE_USER or ~/.Rprofile if it exists:

user_profile = if (Sys.getenv("RENV_PROJECT") != "") FALSE else if (file.exists(".Rprofile")) "project"  else TRUE

Note: I tested the latest devel version of pak and avoided the Bioconductor error (since Bioconductor is now turned off by default); however my ALL_PROXY setting was still not being picked up from my user ~/.Rprofile, but was from a project-specific .Rprofile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants