r-lib / pak

A fresh approach to package installation
https://pak.r-lib.org
639 stars 56 forks source link

pak::pkg_install not downloading from Github when behind a proxy unlike remotes::install_github #620

Open brianrepko opened 2 months ago

brianrepko commented 2 months ago

I'm trying to execute pak::pkg_install("satijalab/seurat-object@visium-hd")

At work, I'm behind a proxy and this fails to download the zip. On my personal laptop, this works - no proxy. At work, the following works however - remotes::install_github("satijalab/seurat-object", ref="visium-hd") So there is something related to proxies and how remotes downloads vs pak.

Running curl from behind the proxy, I need to specify -L to follow redirects as the initial request made returns a 302. Let me know what you might need in terms of logs / output. I figure knowing that remotes works and pak doesn't in the same situation will be be helpful.

gaborcsardi commented 2 months ago

Are you on Windows? Unfortunately libcurl is not so great with proxies. Base R (i.e. remotes) can use native Windows HTTP APIs, which work seamlessly with proxies.

If you are on Windows, what is the output of this?

getOption("download.file.method")
brianrepko commented 2 months ago

Work - Linux (CentOS7.9) and Mac (Ventura - 13.6.6) Home - Mac (Sonoma 14.4.1) On all the systems, getOption('download.file.method') is NULL Are you suggesting using wget?

brianrepko commented 2 months ago

Using wget doesn't work either - this is on Linux behind the proxy

> pak::pkg_install("satijalab/seurat-object@visium-hd")
! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
✔ Updated metadata database: 1.65 MB in 1 file.                               
✔ Updating metadata database ... done                                      

→ Will install 19 packages.
→ All 19 packages (11.13 MB) are cached.
+ cli            3.6.2      [bld][cmp]
+ codetools      0.2-19     [bld]
+ digest         0.6.33     [bld][cmp]
+ dotCall64      1.1-1      [bld][cmp]
+ future         1.33.1     [bld]
+ future.apply   1.11.1     [bld]
+ generics       0.1.3      [bld]
+ globals        0.16.2     [bld]
+ glue           1.6.2      [bld][cmp]
+ lifecycle      1.0.4      [bld]
+ listenv        0.9.0      [bld]
+ parallelly     1.36.0     [bld]
+ progressr      0.14.0     [bld]
+ Rcpp           1.0.11     [bld][cmp]
+ RcppEigen      0.3.3.9.4  [bld][cmp]
+ rlang          1.1.2      [bld][cmp]
+ SeuratObject   5.0.1.9006 [bld][cmp] (GitHub: ee5ea0c)
+ sp             2.1-2      [bld][cmp]
+ spam           2.10-0     [bld][cmp]

ℹ No downloads are needed, 19 pkgs (11.13 MB) are cached
✖ Failed to download SeuratObject 5.0.1.9006 (source)
✔ Got digest 0.6.33 (source) (176.83 kB)
Error: 
! error in pak subprocess
Caused by error: 
! Failed to download SeuratObject from `https://api.github.com/repos/satijalab/seurat-object/zipball/ee5ea0c0b987f574aa27c688ca64de20eff6a5b0`.
Type .Last.error to see the more details.
> getOption('download.file.method')
[1] "wget"
> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error: 
! error in pak subprocess
Caused by error: 
! Failed to download SeuratObject from `https://api.github.com/repos/satijalab/seurat-object/zipball/ee5ea0c0b987f574aa27c688ca64de20eff6a5b0`.
---
Backtrace:
1. pak::pkg_install("satijalab/seurat-object@visium-hd")
2. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pak"))(...), …
3. err$throw(res$error)
---
Subprocess backtrace:
1. base::withCallingHandlers(cli_message = function(msg) { …
2. get("pkg_install_do_plan", asNamespace("pak"))(...)
3. proposal$stop_for_download_error()
4. private$plan$stop_for_solution_download_error()
5. pkgdepends:::pkgplan_stop_for_solution_download_error(self, private)
6. pkgdepends:::stop(err)
7. | base::throw(add_class(args[[1]], c("rlib_error_3_0", "rlib_error"), …
8. | base::signalCondition(cond)
9. global (function (e) …
> 
brianrepko commented 2 months ago

callr is passing environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY, etc) to the subprocess, no?

gaborcsardi commented 2 months ago

callr is passing environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY, etc) to the subprocess, no?

Not actively, no. But environment variables are inherited in general.