r-lib / pak

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

pkg_install install keep returning `readRDS(dbfile)` error #463

Closed sirusb closed 1 year ago

sirusb commented 1 year ago

I am trying to use pak to setup a new conda environment, but it keeps failing with the following message, re-installed the package many time, and tried to install it from diffrent sources (r-pack, from source, ... etc).

> pak::pkg_install('glue')
Error:  3  deps for  1/1  pkgs [⠋] Resolving standard (CRAN/BioC) packages
! error in pak subprocess
Caused by error in `readRDS(dbfile)`:
! error reading from connection
Type .Last.error to see the more details.
gaborcsardi commented 1 year ago

How did you install pak? Please include the full installation output, and also your session information.

sirusb commented 1 year ago

Thanks @gaborcsardi for the quick response.

I installed using the following command: install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))

Also using: install.packages('https://github.com/r-lib/pak/archive/refs/tags/v0.4.0.tar.gz',type='source')

and using : install.packages('pak')

My session info are:

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

Matrix products: default
BLAS/LAPACK: /research/rgs01/home/clusterHome/mdjekide/miniconda3/envs/Rspikein/lib/libopenblasp-r0.3.21.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] pak_0.4.0

loaded via a namespace (and not attached):
 [1] ps_1.7.2          fansi_1.0.4       prettyunits_1.1.1 utf8_1.2.3
 [5] rappdirs_0.3.3    R6_2.5.1          lifecycle_1.0.3   pillar_1.8.1
 [9] rlang_1.0.6       cli_3.6.0         curl_4.3.3        callr_3.7.3
[13] vctrs_0.5.2       filelock_1.0.2    pkgcache_2.0.4    tools_4.2.2
[17] glue_1.6.2        compiler_4.2.2    processx_3.8.0
gaborcsardi commented 1 year ago

What is the full output of install.packages('pak')?

sirusb commented 1 year ago

I got the following output:

> install.packages('pak')
trying URL 'https://cloud.r-project.org/src/contrib/pak_0.4.0.tar.gz'
Content type 'application/x-gzip' length 139041 bytes (135 KB)
==================================================
downloaded 135 KB

* installing *source* package ‘pak’ ...
** package ‘pak’ successfully unpacked and MD5 sums checked
** using staged installation
*** Running ./configure
** R
** data
*** moving datasets to lazyload DB
**** building pak dependency data, this can take several minutes
**** deps data (23): ..........10..........20...23
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (pak)
gaborcsardi commented 1 year ago

OK, now can you call

pak::cache_clean()
pak::meta_clean()

and then try the installation again, and if it fails, then show me the output and also the output of .Last.error after the error?

sirusb commented 1 year ago

The pak::cache_clean() returned the same error message, however, the pak::meta_clean() worked.

I continued with the re-installation anyways, and got the following output:

> pak::pkg_install('glue')
✔ Updated metadata database: 2.70 MB in 6 files.
✔ Updating metadata database ... done
Error:  1  deps for  0/1  pkgs [⠧] Resolving standard (CRAN/BioC) packages
! error in pak subprocess
Caused by error in `readRDS(dbfile)`:
! error reading from connection
Type .Last.error to see the more details.
> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error:
! error in pak subprocess
Caused by error in `readRDS(dbfile)`:
! error reading from connection
---
Backtrace:
1. pak::pkg_install("glue")
2. pak:::remote(function(...) get("pkg_install_make_plan", asNamespace("pak"))(...), …
3. err$throw(res$error)
---
Subprocess backtrace:
 1. base::withCallingHandlers(cli_message = function(msg) { …
 2. get("pkg_install_make_plan", asNamespace("pak"))(...)
 3. prop$solve()
 4. private$plan$solve(policy = private$policy)
 5. pkgdepends:::pkgplan_solve(self, private, match.arg(policy))
 6. self$resolve()
 7. pkgdepends:::pkgplan_resolve(self, private)
 8. pkgdepends:::synchronise(self$async_resolve())
 9. asNamespace("pkgcache")$synchronise(...)
10. base::stop(priv$value)
11. global (function (e) …
gaborcsardi commented 1 year ago

Do these work for you?

install.packages("callr")
callr::r(function() Sys.getpid())
rs <- callr::r_session$new()
rs$run(function()Sys.getpid())
sirusb commented 1 year ago

Yeah, they work, bellow is the output

> install.packages("callr")
callr::r(function() Sys.getpid())
trying URL 'https://cloud.r-project.org/src/contrib/callr_3.7.3.tar.gz'
Content type 'application/x-gzip' length 97813 bytes (95 KB)
==================================================
downloaded 95 KB

* installing *source* package ‘callr’ ...
** package ‘callr’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (callr)

The downloaded source packages are in
        ‘/research/rgs01/scratch_lsf/lsftmpdir/noderome105/182392352.tmpdir/Rtmp0MSCx6/downloaded_packages’
[1] 11241
> rs <- callr::r_session$new()
rs$run(function()Sys.getpid())
[1] 11451
sirusb commented 1 year ago

It seems that the issue in the function pkgcache::pkg_cache_delete_files . When I run pak::cache_clean()

> pak::cache_clean()
Error:
! error in pak subprocess
Caused by error in `readRDS(dbfile)`:
! error reading from connection
Type .Last.error to see the more details.

> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error:
! error in pak subprocess
Caused by error in `readRDS(dbfile)`:
! error reading from connection
---
Backtrace:
1. pak::cache_clean()
2. pak:::remote(function(...) { …
3. err$throw(res$error)
---
Subprocess backtrace:
1. base::withCallingHandlers(cli_message = function(msg) { …
2. get("cache_clean_internal", asNamespace("pak"))(...)
3. pkgcache::pkg_cache_delete_files()
4. package_cache$new(cachepath)$delete(...)
5. private$find_locked(..., .list = .list)
6. base::readRDS(dbfile)
7. base::.handleSimpleError(function (e) …
8. global h(simpleError(msg, call))
gaborcsardi commented 1 year ago

I don't really know what this could be. Does this work?

install.packages("pkgdepends")
pkgcache::pkg_cache_delete_files()
p <- pkgdepends::new_pkg_installation_proposal("glue")
p$solve()
p$download()
p$install()
sirusb commented 1 year ago

Thank you very much for the suggestion, when I use a fresh virtual machine pak installs and works correctly. I also created a singularity image and it works perfectly too. So it is probably something related to my environment, I will try to investigate that.