r-lib / pak

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

[Feature request] Give explicit message when URL fails #501

Open Fan-iX opened 1 year ago

Fan-iX commented 1 year ago

When I am using a CRAN/BioC mirror that doesn't work, install.package and BiocManager::install will show a message that the URL fails:

> options(repos = c(CRAN = "https://a.cran.mirror.that.doesnt.work/"),BioC_mirror="https://a.bioc.mirror.that.doesnt.work/")
> install.packages("ggplot2")
Installing package into ‘/data/lib/R/R4.1/’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://a.cran.mirror.that.doesnt.work/src/contrib:
  cannot open URL 'https://a.cran.mirror.that.doesnt.work/src/contrib/PACKAGES'
> BiocManager::install("BiocGenerics")
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
    CRAN: https://a.cran.mirror.that.doesnt.work/
Warning: unable to access index for repository https://a.bioc.mirror.that.doesnt.work//packages/3.14/bioc/src/contrib:
  cannot open URL 'https://a.bioc.mirror.that.doesnt.work//packages/3.14/bioc/src/contrib/PACKAGES'
Warning: unable to access index for repository https://a.bioc.mirror.that.doesnt.work//packages/3.14/data/annotation/src/contrib:
  cannot open URL 'https://a.bioc.mirror.that.doesnt.work//packages/3.14/data/annotation/src/contrib/PACKAGES'
...

So that I may be able to figure out the problem.

However, pak::pkg_install() doesn't give such message explicitly, it only tells

> pak::pak("ggplot2")
Error:
! error in pak subprocess
Caused by error:
! Could not solve package dependencies:
* ggplot2: Can't find package called ggplot2.
Type .Last.error to see the more details.
> pak::pak("BiocGenerics")
Error:
! error in pak subprocess
Caused by error:
! invalid version specification ‘NA’
Type .Last.error to see the more details.

which doesn't give much useful information and is a little bit confusing.

Is it possible to make the message more clear?

gaborcsardi commented 1 year ago
Type .Last.error to see the more details.

What happens if you do that?

Fan-iX commented 1 year ago
<callr_error/rlib_error_3_0/rlib_error/error>
Error:
! error in pak subprocess
Caused by error:
! Could not solve package dependencies:
* ggplot2: Can't find package called ggplot2.
---
Backtrace:
1. pak::pak("ggplot2")
2. pak::pkg_install(pkg, ...)
3. pak:::remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...), …
4. err$throw(res$error)
---
Subprocess backtrace:
1. base::withCallingHandlers(cli_message = function(msg) { …
2. get("pkg_install_make_plan", asNamespace("pak"))(...)
3. prop$stop_for_solution_error()
4. private$plan$stop_for_solve_error()
5. pkgdepends:::pkgplan_stop_for_solve_error(self, private)
6. base::throw(new_error("Could not solve package dependencies:\n", msg, …
7. | base::signalCondition(cond)
8. global (function (e) …

Seems not much information either.

gaborcsardi commented 1 year ago

I do get

ℹ R 4.3 aarch64-apple-darwin20 packages are missing from CRAN and Bioconductor
ℹ source packages are missing from CRAN and Bioconductor

but yeah, it could be clearer.

jimjam-slam commented 4 months ago

FWIW I use {pak}'s package installer as part of my dev containers, and in that non-interactive context I'm not sure if there's a way to get more information—the backtrace is shown but not the additional error info.