r-lib / pak

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

Operator invalid for atomic vectors, r$version #474

Closed jonlachmann closed 1 year ago

jonlachmann commented 1 year ago

Hi!

I have been using pak on the devel version as I am otherwise experiencing issues with packages that I some of the time want to download from github, and some of the time from CRAN (i.e. to get the latest version, but then go back to CRAN). Yesterday the latest pak devel version worked great, but today I get the error below. It seems to be related to the ppm adjustments made.

To solve this in the meantime, I wonder:

Is there a new stable version of pak planned for release to CRAN? At the moment the issues I am having with packages that are sometimes on CRAN and sometimes on github makes the current CRAN version problematic to use.

Is it possible to get yesterdays devel build somehow?

✔ Loading metadata database ... done
Error: 
! error in pak subprocess
Caused by error in `r$version`:
! $ operator is invalid for atomic vectors
---
Backtrace:
1. pak::local_install(".", ask = F, upgrade = F)
2. pak:::remote(function(...) get("local_install_make_plan", asNamespace("pak"))(...), …
3. err$throw(res$error)
---
Subprocess backtrace:
 1. base::withCallingHandlers(cli_message = function(msg) { …
 2. get("local_install_make_plan", asNamespace("pak"))(...)
 3. pak:::pkg_install_make_plan(pkg, lib, upgrade, ask, start, dependencies, …
 4. prop$solve()
 5. private$plan$solve(policy = private$policy)
 6. pkgdepends:::pkgplan_solve(self, private, match.arg(policy))
 7. private$create_lp_problem(pkgs, policy)
 8. pkgdepends:::pkgplan__create_lp_problem(self, private, pkgs, policy)
 9. pkgdepends:::pkgplan_i_create_lp_problem(pkgs, private$config, policy)
10. pkgdepends:::pkgplan_i_lp_latest_direct(lp)
11. pkgdepends:::vlapply(lp$pkgs$remote, function(r) !is.null(r$version) && r$version != …
12. base::vapply(X, FUN, FUN.VALUE = logical(1), ...)
13. local FUN(X[[i]], ...)
14. base::.handleSimpleError(function (e) …
15. global h(simpleError(msg, call))
Execution halted
gaborcsardi commented 1 year ago

Can you show a reproducible example? E.g. is the package you are experiencing this with public?

jonlachmann commented 1 year ago

Can you show a reproducible example? E.g. is the package you are experiencing this with public?

Hi! The problem is that the package this is occurring with is proprietary... I can try to debug it to see if I can get more information, to see if it is possible to build a minimal reproducible example.

Is it possible to access older versions of the devel prebuilts?

gaborcsardi commented 1 year ago

Is it possible to access older versions of the devel prebuilts?

Yes, with a bit of work. Go to https://github.com/r-lib/pak/blob/a5c1a8408ca93f8ef757b1aca5dd5fca14cb0fba/manifest.json (this is yesterday's version) and look for the sha of the R platform and R version you need. Once you have the sha you can download the package like this, with command line curl:

curl -L -H "Authorization: Bearer QQ==" https://ghcr.io/v2/r-lib/pak/blobs/<sha> -o pak.tar.gz

If you are on macOS name the output file pak.tgz. If you are on Windows, name it pak.zip. Then install it with

R CMD INSTALL <file>

or from R:

install.packages("<file>", repos = NULL, type = "source")

WRT reproducing this, is it OK to show the dependencies of your package? E.g. the output of

desc::desc_get_deps()
desc::desc_get_remotes()
jonlachmann commented 1 year ago

Thanks, then I can probably solve my immediate issue.

I have managed to narrow down the problem a bit. The issue is that when I arrive at this line https://github.com/r-lib/pkgdepends/blob/bd4b34097fe15f7905d2c97c001a21eb13903996/R/solve.R#L470, some of lp$pkgs$remote are NA.

What are the implications of remote being NA here? Is it something that is expected to happen or is it something that is off?

I am not sure I can post all the dependencies here, maybe I could send you a list in private? It is also a bit strange, since I get the error on some computers but not all.

gaborcsardi commented 1 year ago

I don't think lp$pkgs$remote should ever be NA.

gaborcsardi commented 1 year ago

Re dependencies, sure, it is file in private as well.

gaborcsardi commented 1 year ago

What is your OS and R version? Does yesterday's build really fix this issue?

jonlachmann commented 1 year ago

I sent you an email with all the deps.

Running the build from yesterday seems to work, yes. I am thinking it does not have the row from pkgdepends which is causing the issue.

What does lp$pkgs$remote signify? I am trying to understand what the purpose of it is, so I can better assist the debugging!

I am on the machines that are having trouble running Ubuntu 20, and R 4.2.1.

gaborcsardi commented 1 year ago

OK, I think I know how to fix this.

gaborcsardi commented 1 year ago

Let me build new pak devel builds. I assume you are on x86_64.

jonlachmann commented 1 year ago

Let me build new pak devel builds. I assume you are on x86_64.

Yes, correct!

gaborcsardi commented 1 year ago

OK, should be good now.

jonlachmann commented 1 year ago

OK, should be good now.

Can confirm that it works now!