r-lib / pak

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

pak fails to install some package dependencies #484

Closed klmr closed 1 year ago

klmr commented 1 year ago

When running

pak::pak('r-lib/lintr')

I am getting the following error (full output at the end):

Error:
! error in pak subprocess
Caused by error:
! Failed to download xml2 from `https://cloud.r-project.org//src/contrib/xml2_1.3.3.tar.gz` and `https://cloud.r-project.org//src/contrib/Archive/xml2/xml2_1.3.3.tar.gz`.

I am getting the same error both with stable (0.5.0) and nightly (0.5.0.9000). The above error is currently exactly reproducible, but initially I tried it with ‘pak’ v0.4.0 and got a different set of missing packages (including ‘xml2’).

System (version):

platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          4
minor          2.0
year           2022
month          04
day            22
svn rev        82229
language       R
version.string R version 4.2.0 (2022-04-22)
nickname       Vigorous Calisthenics
Full output of pak::pak() ``` ✔ Loading metadata database ... done → Will install 18 packages. → Will download 1 package with unknown size. + backports 1.4.1 [bld][cmp] + callr 3.7.3 [bld] + cli 3.6.1 [bld][cmp] + cyclocomp 1.1.0 [bld] + desc 1.4.2 [bld] + evaluate 0.20 [bld] + highr 0.10 [bld] + knitr 1.42 [bld] + lintr 3.0.2.9000 [bld][cmp][dl] (GitHub: 3a8d495) + processx 3.8.1 [bld][cmp] + ps 1.7.5 [bld][cmp] + remotes 2.4.2 [bld] + rex 1.2.1 [bld] + rprojroot 2.0.3 [bld] + xfun 0.39 [bld][cmp] + xml2 1.3.3 [bld][cmp] + xmlparsedata 1.0.5 [bld] + yaml 2.3.7 [bld][cmp] ℹ Getting 1 pkg with unknown size, 17 (2.84 MB) cached ✔ Cached copy of lintr 3.0.2.9000 (source) is the latest build ✖ Failed to download xml2 1.3.3 (source) ✖ Failed to download 1 package. Error: ! error in pak subprocess Caused by error: ! Failed to download xml2 from `https://cloud.r-project.org//src/contrib/xml2_1.3.3.tar.gz` and `https://cloud.r-project.org//src/contrib/Archive/xml2/xml2_1.3.3.tar.gz`. Type .Last.error to see the more details. ```
gaborcsardi commented 1 year ago

I can't reproduce this in an Ubuntu container. Did you install pak as in https://pak.r-lib.org/#arrow_down-installation or some other way?

klmr commented 1 year ago

Yup, that's the way I used. And for nightly I used the way described here.

gaborcsardi commented 1 year ago

Can you download the file like this?

pak:::remote(
  function() {
    pkgcache:::synchronise(pkgcache:::download_file(
      "https://cloud.r-project.org//src/contrib/xml2_1.3.3.tar.gz", 
      tempfile()
    ))
  }
)
klmr commented 1 year ago

Yes, I think that works: The downloaded file ($destfile) is identical to the one I get when I manually download that URL.

For completeness, rawToChar(.Last.value$response$headers) is

HTTP/1.1 200 OK
Content-Type: application/x-gzip
Content-Length: 283965
Connection: keep-alive
Server: Apache/2.4.39 (Unix)
Last-Modified: Tue, 30 Nov 2021 14:40:02 GMT
Accept-Ranges: bytes
Date: Wed, 26 Apr 2023 07:35:11 GMT
Expires: Wed, 26 Apr 2023 08:05:11 GMT
Cache-Control: max-age=1800
ETag: "4553d-5d20288580c8f"
Vary: Accept-Encoding
X-Cache: Hit from cloudfront
Via: 1.1 a70d280cd058ea89c08954ea0ad67198.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: ZRH50-C1
X-Amz-Cf-Id: waZGNB9s_lvjteskPZFQdISDqj7kmmWCqjck4ggnwYqV0GmK8ljntA==
Age: 22

However, the $response$file differs from $destfile and does not exist, in case that matters.

(I also reran the original pak::pak command and verified that the original issue persists: it wasn’t just a temporary network availability issue.)

gaborcsardi commented 1 year ago

I assume you also get an error for a direct install? I.e.

pak::pkg_install("xml2")

If yes, can you try without the cache, i.e.

pak::pkg_install("xml2?reinstall&nocache")
klmr commented 1 year ago

You are correct (same error); and without cache it works.

gaborcsardi commented 1 year ago

Do you know if you have a HTTP proxy?

Can you try the following?

pak::cache_delete()
pak::pkg_install("xml2")
pak::pkg_remove("xml2")
pak::pkg_install("xml2")
klmr commented 1 year ago

Huh. That worked. And afterwards pak::pak('r-lib/lintr') also runs successfully.

Regarding the HTTP proxy, yes, this is running from inside an HPC in a company network.

gaborcsardi commented 1 year ago

This can still be a bug in pak, so please reopen this or open another issue if you see this again.