pkgdepends icon indicating copy to clipboard operation
pkgdepends copied to clipboard

"Internal error, no task running and cannot select new task" while installing knitr

Open zkamvar opened this issue 3 years ago • 11 comments

I am getting an internal error while trying to install knitr:

tmplib <- tempfile()
dir.create(tmplib)
pak::cache_delete()
pak::pkg_install("knitr", lib = tmplib, upgrade = FALSE, dependencies = FALSE)

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 
> tmplib <- tempfile()
> dir.create(tmplib)
> 
> pak::cache_delete() 
> pak::pkg_install("knitr", lib = tmplib, upgrade = FALSE, dependencies = FALSE)
ℹ Loading metadata database
✔ Loading metadata database ... done

 
→ Will install 1 package.
→ Will download 1 CRAN package (896.12 kB).
+ knitr   1.36 [bld][dl] (896.12 kB)
ℹ Getting 1 pkg (896.12 kB)
✔ Got knitr 1.36 (source) (896.12 kB)

Error: <callr_remote_error: Internal error, no task running and cannot select new task>
 in process 66184 
-->
<simpleError in select_next_task(state): Internal error, no task running and cannot select new task>

 Stack trace:

 12. (function (...)  ...
 13. base:::withCallingHandlers(cli_message = function(msg) { ...
 14. get("pkg_install_do_plan", asNamespace("pak"))(...)
 15. pkgdepends::install_package_plan(plan = plan, lib = lib, num_workers = num_ ...
 16. base:::withCallingHandlers({ ...
 17. pkgdepends:::select_next_task(state)
 18. base:::stop("Internal error, no task running and cannot select new task")
 19. base:::.handleSimpleError(function (e)  ...
 20. h(simpleError(msg, call))
 21. base:::stop(e)
 22. (function (e)  ...

 x Internal error, no task running and cannot select new task 

Execution halted

Context

I ran into this on GitHub Actions when I was trying to shoehorn a solution for r-lib/pak#343. I was taking the package names from a lockfile (this lockfile in particular) and tried to install them.

Sometimes I get the "no task running and cannot select new task" error, but I have also gotten a "subscript out of bounds" error

zkamvar avatar Dec 15 '21 19:12 zkamvar

Yes, that seems like a bug, triggered by the rarely used dependencies = FALSE option.

Reprex:

tmplib <- tempfile()
p <- pkgdepends::new_pkg_installation_proposal(
  "knitr?source", 
  config = list(library = tmplib, dependencies = FALSE)
)
#> ℹ Creating library directory: 
#> /var/folders/ph/fpcmzfd16rgbbk8mxvy9m2_h0000gn/T//RtmpXI5ULd/file4c42498721d7

p$solve()
p$download()
#> ℹ No downloads are needed, 1 pkg (896.12 kB) is cached

p$install()
#> Error in select_next_task(state) :
#>   Internal error, no task running and cannot select new task
p$get_install_plan()$dependencies
#> [[1]]
#> [1] "evaluate" "highr"    "stringr"  "yaml"     "xfun"

p$get_install_plan()$dep_types
#> [[1]]
#> character(0)

$dependencies should be probably empty if $dep_types is empty.

gaborcsardi avatar Dec 15 '21 20:12 gaborcsardi

Why would you use dependencies = FALSE, btw?

gaborcsardi avatar Dec 15 '21 20:12 gaborcsardi

The original context was extracting packages from a renv.lock file, where the dependencies were enumerated. I set dependencies = FALSE because I (perhaps foolishly) thought that this would speed things up.

zkamvar avatar Dec 15 '21 22:12 zkamvar

Well, if you manually extract the dependencies from the renv JSON and pass them to pak one by one, that'll not speed things up, as there is no concurrency. It is also hard to do because you would need to install them in the right dependency order.

If you pass all of them at once that might work. Or just wait for https://github.com/r-lib/pak/issues/343

gaborcsardi avatar Dec 16 '21 09:12 gaborcsardi

If you pass all of them at once that might work.

I thought so too, and this is what I did (the above was just a MWE). Theoretically, there is no performance hit if I specify dependencies = TRUE when I pass the dependencies from a fully-provisioned {renv} file?

zkamvar avatar Dec 16 '21 15:12 zkamvar

Maybe? pak will still resolve all dependencies again, and might en up with different package versions of course, if you just pass the package names. Or won't be able to find a package if it is from a non-standard source.

gaborcsardi avatar Dec 16 '21 16:12 gaborcsardi

I’ve just encountered this error too.

My use-case is that I am positive that the dependencies are already all installed, and leaving off dependencies = FALSE fails because some of the the dependencies cannot be found in the CRAN archive. For example,

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

Currently yields the following for me:

✖ Failed to download 1 packages 
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`.

klmr avatar Apr 25 '23 13:04 klmr

@klmr What version and build of pak is this? What os? Also, your error looks different from what the OP was seeing, no?

gaborcsardi avatar Apr 25 '23 13:04 gaborcsardi

@gaborcsardi I'll report this independently as a bug (and I just edited the error message after updating, apologies).

I posted here to justify why one might be using dependencies = FALSE (in which case I am seeing the same error message as OP).

klmr avatar Apr 25 '23 13:04 klmr

The cran archive is a red herring, pak tries both URLs and the first should be clearly working, at least it is right now for me.

gaborcsardi avatar Apr 25 '23 13:04 gaborcsardi

Cross-reference to the other issue: r-lib/pak#484

klmr avatar Apr 25 '23 14:04 klmr