Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renv 0.17.0 issues with provisioning non-CRAN packages #1156

Closed
zkamvar opened this issue Mar 6, 2023 · 9 comments
Closed

renv 0.17.0 issues with provisioning non-CRAN packages #1156

zkamvar opened this issue Mar 6, 2023 · 9 comments

Comments

@zkamvar
Copy link
Contributor

zkamvar commented Mar 6, 2023

update: I have determined that the problem lies with how {renv} handles non-CRAN repositories mixed with CRAN repositories. Details in #1156 (comment)


Problem

If I try to use renv::install() with a bioconductor package (e.g. renv::install("bioc::SummarizedExperiment") (related to #1110), the process fails:

Note: I am using the most recent GitHub version of {renv}: https://github.com/rstudio/renv/tree/0.17.0-16

(to avoid having to copy/paste/delete, here is the reprex code to generate the output)
reprex::reprex({ 
    tmp <- tempfile() 
    dir.create(tmp) 
    writeLines("library(SummarizedExperiment)", file.path(tmp, "test.R")) 
    setwd(tmp) 
    renv::init() 
    renv::install("bioc::SummarizedExperiment") 
  }, std_out_err = TRUE, html_preview = FALSE, si = TRUE)
tmp <- tempfile()
dir.create(tmp)
writeLines("library(SummarizedExperiment)", file.path(tmp, "test.R"))
setwd(tmp)
renv::init()
#> * Discovering package dependencies ... Done!
#> * Resolving missing dependencies  ...
#> Warning in value[[3L]](cond): restarting interrupted promise evaluation
#> The version of R recorded in the lockfile will be updated:
#> - R      [* -> 4.2.2]
#> 
#> * Lockfile written to '/tmp/RtmpZBW61e/file1222c1c0355c7/renv.lock'.
renv::install("bioc::SummarizedExperiment")
#> Warning in value[[3L]](cond): restarting interrupted promise evaluation
#> Error in object[[i]]: object of type 'promise' is not subsettable

Created on 2023-03-06 with reprex v2.0.2

Standard output and standard error
The following package(s) were not installed successfully:

	[SummarizedExperiment]: object of type 'promise' is not subsettable

You may need to manually download and install these packages.

The following package(s) will be updated in the lockfile:

# GitHub =============================
- renv   [* -> rstudio/renv@HEAD]

Warning message:
In in_dir(input_dir(), expr) :
  You changed the working directory to /tmp/RtmpZBW61e/file1222c1c0355c7 (probably via setwd()). It will be restored to /tmp/Rtmpq9deYv/reprex-119ec1e7646a0-plump-imago. See the Note section in ?knitr::knit
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/codetools': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/compiler': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/datasets': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/grDevices': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/Matrix': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/KernSmooth': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/boot': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/lattice': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/grid': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/mgcv': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/nnet': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/MASS': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/parallel': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/graphics': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/stats': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/spatial': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/splines': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/stats4': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/cluster': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/class': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/survival': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/tcltk': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/utils': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/rpart': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/tools': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/methods': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/foreign': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/nlme': Permission denied
rm: cannot remove '/tmp/RtmpZBW61e/file1222c1c0355c7/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72/base': Permission denied

The process now fails with a message that says "object of type 'promise' is not subsettable" and I now have a sandbox folder that I can no longer remove without sudo even though its permissions are set to my user.

This was originally reported in carpentries-incubator/bioc-intro#82 where they were seeing this behavior in a previously working lesson: Here is a backtrace of the error from the log:

   1. renv::install(paste0("bioc::", pkgs), library = renv_lib, project = path)
   2. renv:::retrieve(names(remotes))
   3. local handler(package, renv_retrieve_impl(package))
   4. renv:::renv_retrieve_impl(package)
   5. renv:::renv_scope_bioconductor(project = project)
   6. renv:::renv_bioconductor_repos(project = project, version = version)
   7. renv:::renv_bioconductor_repos_biocmanager(version)
   8. base::asNamespace("BiocManager")
   9. base::getNamespace(ns)
  10. base::loadNamespace(name)

version 0.16.0 behavior

I could previously rescue failed bootstraps of BioConductor packages by using bioc::<PKG> with renv::install():

tmp <- tempfile()
dir.create(tmp)
writeLines("library(SummarizedExperiment)", file.path(tmp, "test.R"))
setwd(tmp)
renv::init()
#> * Initializing project ...
#> * Discovering package dependencies ... Done!
#> * Copying packages into the cache ... Done!
#> * Resolving missing dependencies  ... 
#> The version of R recorded in the lockfile will be updated:
#> - R      [*] -> [4.2.2]
#> 
#> * Lockfile written to '/tmp/RtmpZguXe0/file11f522de55c41/renv.lock'.
renv::install("bioc::SummarizedExperiment")
#> Installing BiocManager [1.30.20] ...
#>  OK [linked cache]
#> Installing BiocGenerics [0.44.0] ...
#>  OK [linked cache]
#> Installing S4Vectors [0.36.2] ...
#>  OK [linked cache]
#> Installing IRanges [2.32.0] ...
#>  OK [linked cache]
#> Installing bitops [1.0-7] ...
#>  OK [linked cache]
#> Installing RCurl [1.98-1.10] ...
#>  OK [linked cache]
#> Installing GenomeInfoDbData [1.2.9] ...
#>  OK [linked cache]
#> Installing GenomeInfoDb [1.34.9] ...
#>  OK [linked cache]
#> Installing matrixStats [0.63.0] ...
#>  OK [linked cache]
#> Installing MatrixGenerics [1.10.0] ...
#>  OK [linked cache]
#> Installing DelayedArray [0.24.0] ...
#>  OK [linked cache]
#> Installing zlibbioc [1.44.0] ...
#>  OK [linked cache]
#> Installing XVector [0.38.0] ...
#>  OK [linked cache]
#> Installing GenomicRanges [1.50.2] ...
#>  OK [linked cache]
#> Installing Biobase [2.58.0] ...
#>  OK [linked cache]
#> Installing SummarizedExperiment [1.28.0] ...
#>  OK [linked cache]

Created on 2023-03-06 with reprex v2.0.2

Standard output and standard error
The following package(s) were not installed successfully:

	[SummarizedExperiment]: package 'SummarizedExperiment' is not available

You may need to manually download and install these packages.

The following package(s) will be updated in the lockfile:

# CRAN ===============================
- renv   [* -> 0.16.0]

Warning message:
In in_dir(input_dir(), expr) :
  You changed the working directory to /tmp/RtmpZguXe0/file11f522de55c41 (probably via setwd()). It will be restored to /tmp/Rtmpq9deYv/reprex-119ec2839ead2-deep-polyp. See the Note section in ?knitr::knit
@kevinushey
Copy link
Collaborator

This appears to be fixed for me:

* Project '/private/var/folders/9n/3nxsgkrj0rlfx196kzdttpww0000gn/T/tmp.DKFIWyo5' loaded. [renv 0.17.0-19]
> renv::install("bioc::SummarizedExperiment")
Installing BiocManager [1.30.20] ...
        OK [linked cache in 0.61 milliseconds]
* Installed 1 package in 1.4 second.
Retrieving 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/matrixStats_0.63.0.tgz' ...
        OK [file is up to date]
Installing BiocGenerics [0.44.0] ...
        OK [linked cache in 0.2 milliseconds]
Installing S4Vectors [0.36.2] ...
        OK [linked cache in 0.18 milliseconds]
Installing IRanges [2.32.0] ...
        OK [linked cache in 0.16 milliseconds]
Installing bitops [1.0-7] ...
        OK [linked cache in 0.15 milliseconds]
Installing RCurl [1.98-1.10] ...
        OK [linked cache in 0.14 milliseconds]
Installing GenomeInfoDbData [1.2.9] ...
        OK [linked cache in 0.15 milliseconds]
Installing GenomeInfoDb [1.34.9] ...
        OK [linked cache in 0.15 milliseconds]
Installing matrixStats [0.63.0] ...
        OK [installed binary in 0.47 seconds]
Moving matrixStats [0.63.0] into the cache ...
        OK [moved to cache in 0.68 milliseconds]
Installing MatrixGenerics [1.10.0] ...
        OK [linked cache in 0.16 milliseconds]
Installing DelayedArray [0.24.0] ...
        OK [linked cache in 0.15 milliseconds]
Installing zlibbioc [1.44.0] ...
        OK [linked cache in 0.15 milliseconds]
Installing XVector [0.38.0] ...
        OK [linked cache in 0.15 milliseconds]
Installing GenomicRanges [1.50.2] ...
        OK [linked cache in 0.15 milliseconds]
Installing Biobase [2.58.0] ...
        OK [linked cache in 0.15 milliseconds]
Installing SummarizedExperiment [1.28.0] ...
        OK [linked cache in 0.17 milliseconds]
* Installed 15 packages in 4.4 seconds.

@zkamvar
Copy link
Contributor Author

zkamvar commented Mar 7, 2023

Unfortunately I'm still getting the error with 9fd57df:

tmp <- tempfile()
dir.create(tmp)
writeLines("library(SummarizedExperiment)", file.path(tmp, "test.R"))
setwd(tmp)
renv::init()
#> * Discovering package dependencies ... Done!
#> * Resolving missing dependencies  ...
#> Warning in value[[3L]](cond): restarting interrupted promise evaluation
#> The version of R recorded in the lockfile will be updated:
#> - R      [* -> 4.2.2]
#> 
#> * Lockfile written to '/tmp/RtmpMHVYvp/file444e4877ccda/renv.lock'.
renv::install("bioc::SummarizedExperiment")
#> Warning in value[[3L]](cond): restarting interrupted promise evaluation
#> Error in object[[i]]: object of type 'promise' is not subsettable

Created on 2023-03-07 with reprex v2.0.2

Standard output and standard error
The following package(s) were not installed successfully:

	[SummarizedExperiment]: object of type 'promise' is not subsettable

You may need to manually download and install these packages.

The following package(s) will be updated in the lockfile:

# GitHub =============================
- renv   [* -> rstudio/renv@HEAD]

Warning message:
In in_dir(input_dir(), expr) :
  You changed the working directory to /tmp/RtmpMHVYvp/file444e4877ccda (probably via setwd()). It will be restored to /tmp/RtmpjnVuOY/reprex-3e0863d0d575-awful-dog. See the Note section in ?knitr::knit
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 Patched (2022-11-10 r83330)
#>  os       Ubuntu 20.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US:en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Los_Angeles
#>  date     2023-03-07
#>  pandoc   2.12 @ /home/zhian/anaconda3/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version   date (UTC) lib source
#>  R cli           3.6.0     <NA>       [?] <NA>
#>  R digest        0.6.31    <NA>       [?] <NA>
#>  R evaluate      0.20      <NA>       [?] <NA>
#>  R fastmap       1.1.1     <NA>       [?] <NA>
#>  R fs            1.6.1     <NA>       [?] <NA>
#>  R glue          1.6.2     <NA>       [?] <NA>
#>  R htmltools     0.5.4     <NA>       [?] <NA>
#>  R knitr         1.42      <NA>       [?] <NA>
#>  R lifecycle     1.0.3     <NA>       [?] <NA>
#>  R magrittr      2.0.3     <NA>       [?] <NA>
#>  R purrr         1.0.1     <NA>       [?] <NA>
#>  R R.cache       0.16.0    <NA>       [?] <NA>
#>  R R.methodsS3   1.8.2     <NA>       [?] <NA>
#>  R R.oo          1.25.0    <NA>       [?] <NA>
#>  R R.utils       2.12.2    <NA>       [?] <NA>
#>  P renv          0.17.0-22 2023-03-07 [?] Github (rstudio/renv@9fd57df)
#>  R reprex        2.0.2     <NA>       [?] <NA>
#>  R rlang         1.0.6     <NA>       [?] <NA>
#>  R rmarkdown     2.20      <NA>       [?] <NA>
#>  R sessioninfo   1.2.2     <NA>       [?] <NA>
#>  R styler        1.9.1     <NA>       [?] <NA>
#>  R vctrs         0.5.2     <NA>       [?] <NA>
#>  R withr         2.5.0     <NA>       [?] <NA>
#>  R xfun          0.37      <NA>       [?] <NA>
#>  R yaml          2.3.7     <NA>       [?] <NA>
#> 
#>  [1] /tmp/RtmpMHVYvp/file444e4877ccda/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /tmp/RtmpMHVYvp/file444e4877ccda/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72
#> 
#>  P ── Loaded and on-disk path mismatch.
#>  R ── Package was removed from disk.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Here is the traceback:

15: renv::install("bioc::SummarizedExperiment")
14: retrieve(names(remotes))
13: handler(package, renv_retrieve_impl(package))
12: renv_retrieve_impl(package)
11: renv_scope_bioconductor(project = project)
10: renv_bioconductor_repos(project = project, version = version)
 9: renv_bioconductor_init()
 8: renv_bioconductor_init_biocmanager(library)
 7: install("BiocManager", library = library)
 6: retrieve(names(remotes))
 5: handler(package, renv_retrieve_impl(package))
 4: renv_retrieve_impl(package)
 3: renv_available_packages_latest(package)
 2: stopf("package '%s' is not available", package)
 1: stop(sprintf(fmt, ...), call. = call.)

zkamvar added a commit to carpentries/sandpaper that referenced this issue Mar 7, 2023
this will help prevent failures until rstudio/renv#1156
is fixed.
@zkamvar
Copy link
Contributor Author

zkamvar commented Mar 7, 2023

Note: this is not just a problem with Bioc:

tmp <- tempfile()
dir.create(tmp)
writeLines("1 + 1", file.path(tmp, "test.R"))
setwd(tmp)
renv::init()
#> * Discovering package dependencies ... Done!
#> Warning in value[[3L]](cond): restarting interrupted promise evaluation
#> The version of R recorded in the lockfile will be updated:
#> - R      [* -> 4.2.2]
#> 
#> * Lockfile written to '/tmp/RtmpR0tPjC/file145a2135215a9/renv.lock'.
renv::install("cowsay")
#> Warning in value[[3L]](cond): restarting interrupted promise evaluation

#> Warning in value[[3L]](cond): restarting interrupted promise evaluation
#> Error in object[[i]]: object of type 'promise' is not subsettable

Created on 2023-03-07 with reprex v2.0.2

Standard output and standard error
The following package(s) will be updated in the lockfile:

# GitHub =============================
- renv   [* -> rstudio/[email protected]]

Warning message:
In in_dir(input_dir(), expr) :
  You changed the working directory to /tmp/RtmpR0tPjC/file145a2135215a9 (probably via setwd()). It will be restored to /tmp/RtmpHqgOuS/reprex-139322b756a18-hexed-tuna. See the Note section in ?knitr::knit
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 Patched (2022-11-10 r83330)
#>  os       Ubuntu 20.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US:en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Los_Angeles
#>  date     2023-03-07
#>  pandoc   2.12 @ /home/zhian/anaconda3/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version   date (UTC) lib source
#>  R cli           3.6.0     <NA>       [?] <NA>
#>  R digest        0.6.31    <NA>       [?] <NA>
#>  R evaluate      0.20      <NA>       [?] <NA>
#>  R fastmap       1.1.1     <NA>       [?] <NA>
#>  R fs            1.6.1     <NA>       [?] <NA>
#>  R glue          1.6.2     <NA>       [?] <NA>
#>  R htmltools     0.5.4     <NA>       [?] <NA>
#>  R knitr         1.42      <NA>       [?] <NA>
#>  R lifecycle     1.0.3     <NA>       [?] <NA>
#>  R magrittr      2.0.3     <NA>       [?] <NA>
#>  R purrr         1.0.1     <NA>       [?] <NA>
#>  R R.cache       0.16.0    <NA>       [?] <NA>
#>  R R.methodsS3   1.8.2     <NA>       [?] <NA>
#>  R R.oo          1.25.0    <NA>       [?] <NA>
#>  R R.utils       2.12.2    <NA>       [?] <NA>
#>  P renv          0.17.0-22 2023-03-07 [?] local
#>  R reprex        2.0.2     <NA>       [?] <NA>
#>  R rlang         1.0.6     <NA>       [?] <NA>
#>  R rmarkdown     2.20      <NA>       [?] <NA>
#>  R sessioninfo   1.2.2     <NA>       [?] <NA>
#>  R styler        1.9.1     <NA>       [?] <NA>
#>  R vctrs         0.5.2     <NA>       [?] <NA>
#>  R withr         2.5.0     <NA>       [?] <NA>
#>  R xfun          0.37      <NA>       [?] <NA>
#>  R yaml          2.3.7     <NA>       [?] <NA>
#> 
#>  [1] /tmp/RtmpR0tPjC/file145a2135215a9/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /tmp/RtmpR0tPjC/file145a2135215a9/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72
#> 
#>  P ── Loaded and on-disk path mismatch.
#>  R ── Package was removed from disk.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

@zkamvar
Copy link
Contributor Author

zkamvar commented Mar 7, 2023

I think I understand what's happening now: I have the r-universe set as one of my repositories.

If I set my repositories to the default CRAN, then I get no error:

   tmp <- tempfile() 
   dir.create(tmp) 
   writeLines("1 + 1", file.path(tmp, "test.R")) 
   setwd(tmp) 
   renv::init(repos = c("https://cran.r-project.org"))
#> * Discovering package dependencies ... Done!
#> The version of R recorded in the lockfile will be updated:
#> - R      [* -> 4.2.2]
#> 
#> * Lockfile written to '/tmp/RtmpShym2N/file1c59a3b01be0e/renv.lock'.
   renv::install("cowsay")
#> Installing crayon [1.5.2] ...
#>  OK [linked cache in 0.11 milliseconds]
#> Installing fortunes [1.5-4] ...
#>  OK [linked cache in 0.097 milliseconds]
#> Installing rmsfact [0.0.3] ...
#>  OK [linked cache in 0.094 milliseconds]
#> Installing cowsay [0.8.0] ...
#>  OK [linked cache in 0.11 milliseconds]
#> * Installed 4 packages in 43 milliseconds.

Created on 2023-03-07 with reprex v2.0.2

Standard output and standard error
The following package(s) will be updated in the lockfile:

# CRAN ===============================
- renv   [* -> 0.17.0-22]

Warning message:
In in_dir(input_dir(), expr) :
  You changed the working directory to /tmp/RtmpShym2N/file1c59a3b01be0e (probably via setwd()). It will be restored to /tmp/RtmpNtvTbJ/reprex-1b9c552a5b445-drear-kitty. See the Note section in ?knitr::knit
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 Patched (2022-11-10 r83330)
#>  os       Ubuntu 20.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US:en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Los_Angeles
#>  date     2023-03-07
#>  pandoc   2.12 @ /home/zhian/anaconda3/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version   date (UTC) lib source
#>  R cli           3.6.0     <NA>       [?] <NA>
#>  R digest        0.6.31    <NA>       [?] <NA>
#>  R evaluate      0.20      <NA>       [?] <NA>
#>  R fastmap       1.1.1     <NA>       [?] <NA>
#>  R fs            1.6.1     <NA>       [?] <NA>
#>  R glue          1.6.2     <NA>       [?] <NA>
#>  R htmltools     0.5.4     <NA>       [?] <NA>
#>  R knitr         1.42      <NA>       [?] <NA>
#>  R lifecycle     1.0.3     <NA>       [?] <NA>
#>  R magrittr      2.0.3     <NA>       [?] <NA>
#>  R purrr         1.0.1     <NA>       [?] <NA>
#>  R R.cache       0.16.0    <NA>       [?] <NA>
#>  R R.methodsS3   1.8.2     <NA>       [?] <NA>
#>  R R.oo          1.25.0    <NA>       [?] <NA>
#>  R R.utils       2.12.2    <NA>       [?] <NA>
#>  P renv          0.17.0-22 2023-03-07 [?] local
#>  R reprex        2.0.2     <NA>       [?] <NA>
#>  R rlang         1.0.6     <NA>       [?] <NA>
#>  R rmarkdown     2.20      <NA>       [?] <NA>
#>  R sessioninfo   1.2.2     <NA>       [?] <NA>
#>  R styler        1.9.1     <NA>       [?] <NA>
#>  R vctrs         0.5.2     <NA>       [?] <NA>
#>  R withr         2.5.0     <NA>       [?] <NA>
#>  R xfun          0.37      <NA>       [?] <NA>
#>  R yaml          2.3.7     <NA>       [?] <NA>
#> 
#>  [1] /tmp/RtmpShym2N/file1c59a3b01be0e/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /tmp/RtmpShym2N/file1c59a3b01be0e/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72
#> 
#>  P ── Loaded and on-disk path mismatch.
#>  R ── Package was removed from disk.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

However, once I add the Carpentries universe, things go haywire:

   tmp <- tempfile() 
   dir.create(tmp) 
   writeLines("1 + 1", file.path(tmp, "test.R")) 
   setwd(tmp) 
   renv::init(repos = c("https://carpentries.r-universe.dev", "https://cran.r-project.org"))
#> * Discovering package dependencies ... Done!
#> Warning in value[[3L]](cond): restarting interrupted promise evaluation
#> The version of R recorded in the lockfile will be updated:
#> - R      [* -> 4.2.2]
#> 
#> * Lockfile written to '/tmp/RtmpBRKoYF/file1c2995b709133/renv.lock'.
   renv::install("cowsay")
#> Warning in value[[3L]](cond): restarting interrupted promise evaluation

#> Warning in value[[3L]](cond): restarting interrupted promise evaluation
#> Error in object[[i]]: object of type 'promise' is not subsettable

Created on 2023-03-07 with reprex v2.0.2

Standard output and standard error
The following package(s) will be updated in the lockfile:

# GitHub =============================
- renv   [* -> rstudio/[email protected]]

Warning message:
In in_dir(input_dir(), expr) :
  You changed the working directory to /tmp/RtmpBRKoYF/file1c2995b709133 (probably via setwd()). It will be restored to /tmp/RtmpNtvTbJ/reprex-1b9c56a6d2a44-woody-kiwi. See the Note section in ?knitr::knit
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 Patched (2022-11-10 r83330)
#>  os       Ubuntu 20.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US:en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Los_Angeles
#>  date     2023-03-07
#>  pandoc   2.12 @ /home/zhian/anaconda3/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version   date (UTC) lib source
#>  R cli           3.6.0     <NA>       [?] <NA>
#>  R digest        0.6.31    <NA>       [?] <NA>
#>  R evaluate      0.20      <NA>       [?] <NA>
#>  R fastmap       1.1.1     <NA>       [?] <NA>
#>  R fs            1.6.1     <NA>       [?] <NA>
#>  R glue          1.6.2     <NA>       [?] <NA>
#>  R htmltools     0.5.4     <NA>       [?] <NA>
#>  R knitr         1.42      <NA>       [?] <NA>
#>  R lifecycle     1.0.3     <NA>       [?] <NA>
#>  R magrittr      2.0.3     <NA>       [?] <NA>
#>  R purrr         1.0.1     <NA>       [?] <NA>
#>  R R.cache       0.16.0    <NA>       [?] <NA>
#>  R R.methodsS3   1.8.2     <NA>       [?] <NA>
#>  R R.oo          1.25.0    <NA>       [?] <NA>
#>  R R.utils       2.12.2    <NA>       [?] <NA>
#>  P renv          0.17.0-22 2023-03-07 [?] local
#>  R reprex        2.0.2     <NA>       [?] <NA>
#>  R rlang         1.0.6     <NA>       [?] <NA>
#>  R rmarkdown     2.20      <NA>       [?] <NA>
#>  R sessioninfo   1.2.2     <NA>       [?] <NA>
#>  R styler        1.9.1     <NA>       [?] <NA>
#>  R vctrs         0.5.2     <NA>       [?] <NA>
#>  R withr         2.5.0     <NA>       [?] <NA>
#>  R xfun          0.37      <NA>       [?] <NA>
#>  R yaml          2.3.7     <NA>       [?] <NA>
#> 
#>  [1] /tmp/RtmpBRKoYF/file1c2995b709133/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /tmp/RtmpBRKoYF/file1c2995b709133/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72
#> 
#>  P ── Loaded and on-disk path mismatch.
#>  R ── Package was removed from disk.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Note: I have tested this with the bioc packages and it also succeeds when I take away the universe.

Digging into the errors

The R-universe registry does not have src/contrib/PACKAGES.rds, but it does have src/contrib/PACKAGES.gz. In renv_available_packages_query(), the search is for rds, then gz, then plaintext:

renv_available_packages_query <- function(url, errors) {
# define query methods for the different PACKAGES
methods <- list(
renv_available_packages_query_packages_rds,
renv_available_packages_query_packages_gz,
renv_available_packages_query_packages
)
stack <- stack()
seize <- function(restart) {
function(condition) {
stack$push(condition)
invokeRestart(restart)
}
}
for (method in methods) {
db <- withCallingHandlers(
catch(method(url)),
warning = seize(restart = "muffleWarning"),
message = seize(restart = "muffleMessage")
)
if (inherits(db, "error")) {
stack$push(db)
next
}
return(renv_available_packages_success(db, url))
}

While the error propogation is catching this, there is something happening in the mechanism where the error object stored is not parsed correctly.

I ran renv::install("cowsay") with options(error = recover) and dug into the the stack:

> renv::install("cowsay")
Error: package 'cowsay' is not available
In addition: Warning messages:
1: In value[[3L]](cond) : restarting interrupted promise evaluation
2: In value[[3L]](cond) : restarting interrupted promise evaluation
3: In object[[i]] : object of type 'promise' is not subsettable

Enter a frame number, or 0 to exit

1: renv::install("cowsay")
2: retrieve(names(remotes))
3: handler(package, renv_retrieve_impl(package))
4: renv_retrieve_impl(package)
5: renv_available_packages_latest(package)
6: stopf("package '%s' is not available", package)

Selection: 5

I then looked at the objects in

renv_available_packages_latest <- function(package,

and selected the errors object to get the traceback:

Traceback of errors object
errors$data()[[1]]$message
[1] "object of type 'promise' is not subsettable"

errors$data()[[1]]$traceback
36: renv::install("cowsay")
35: retrieve(names(remotes))
34: handler(package, renv_retrieve_impl(package))
33: renv_retrieve_impl(package)
32: renv_available_packages_latest(package)
31: lapply(methods, function(method) {
        if (is.null(method))
            return(NULL)
        entry <- catch(method(package, type, repos))
        if (inherits(entry, "error")) {
            errors$push(entry)
            return(NULL)
        }
        entry
    })
30: FUN(X[[i]], ...)
29: catch(method(package, type, repos))
28: tryCatch(withCallingHandlers(expr, error = renv_error_capture),
        error = renv_error_tag)
27: tryCatchList(expr, classes, parentenv, handlers)
26: tryCatchOne(expr, names, parentenv, handlers[[1L]])
25: doTryCatch(return(expr), name, parentenv, handler)
24: withCallingHandlers(expr, error = renv_error_capture)
23: method(package, type, repos)
22: renv_available_packages_latest_repos_impl(package, "source",
        repos)
21: available_packages(type = type, repos = repos, quiet = TRUE)
20: index(scope = "available-packages", key = key, value = renv_available_packages
_impl(type,
        repos, quiet), limit = as.integer(limit))
19: tryCatch(renv_index_impl(root, scope, key, value, now, limit),
        error = function(e) value)
18: tryCatchList(expr, classes, parentenv, handlers)
17: tryCatchOne(expr, names, parentenv, handlers[[1L]])
16: value[[3L]](cond)
15: renv_available_packages_impl(type, repos, quiet)
14: lapply(urls, renv_available_packages_query, errors = errors)
13: FUN(X[[i]], ...)
12: withCallingHandlers(catch(method(url)), warning = seize(restart = "muffleWarni
ng"),
        message = seize(restart = "muffleMessage"))
11: catch(method(url))
10: tryCatch(withCallingHandlers(expr, error = renv_error_capture),
        error = renv_error_tag)
 9: tryCatchList(expr, classes, parentenv, handlers)
 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 7: doTryCatch(return(expr), name, parentenv, handler)
 6: withCallingHandlers(expr, error = renv_error_capture)
 5: method(url)
 4: download(url = path, destfile = destfile, quiet = TRUE)
 3: renv_download_error(url, "%s", conditionMessage(status))
 2: stopf("error downloading '%s' [%s]", url, msg, call. = FALSE)
 1: stop(sprintf(fmt, ...), call. = call.)

Looking further into this, it the specific error is coming from

renv/R/errors.R

Lines 50 to 67 in 9fd57df

renv_error_simplify_recursive <- function(object) {
longcall <-
is.call(object) &&
is.symbol(object[[1]]) &&
object[[1]] == as.name("{") &&
length(object) >= 8
if (longcall)
return(quote(...))
for (i in seq_along(object))
if (!is.null(object[[i]]))
object[[i]] <- renv_error_simplify(object[[i]])
object
}

where the object is a promise:

Browse[3]> object
<promise: 0x560ef1e98ff0>

Browse[3]> str(object)
 promise to  symbol url

Browse[3]> eval(object)
[1] "https://carpentries.r-universe.dev/src/contrib"

The only thing is I'm having a really difficult time figuring out where that promise slipped in.

@zkamvar zkamvar changed the title renv 0.17.0 unable to use bioc:: prefix renv 0.17.0 issues with provisioning non-CRAN packages Mar 7, 2023
@kevinushey
Copy link
Collaborator

Thank you! I'll see if I can reproduce with those instructions.

@kevinushey
Copy link
Collaborator

Ok, I can reproduce. I think I know what's going on -- the available packages database returned by r-universe doesn't include some fields; e.g. "OS_type", and we're failing to account for that. I'll try to fix this up.

@kevinushey
Copy link
Collaborator

Should be fixed with 7aa92a0. Let me know if that does the trick for you.

zkamvar added a commit to carpentries/carpentries.r-universe.dev that referenced this issue Mar 7, 2023
This will address carpentries/sandpaper#406 and rstudio/renv#1156 until the next version of {renv} is sent to CRAN
@zkamvar
Copy link
Contributor Author

zkamvar commented Mar 7, 2023

It woorrrkssss! Thank you for being so quick in fixing this!

   tmp <- tempfile() 
   dir.create(tmp) 
   writeLines("library(SummarizedExperiment)", file.path(tmp, "test.R")) 
   setwd(tmp) 
   renv::init(repos = c("https://carpentries.r-universe.dev/", "https://cran.r-project.org/")) 
#> * Discovering package dependencies ... Done!
#> * Resolving missing dependencies  ... 
#> The version of R recorded in the lockfile will be updated:
#> - R      [* -> 4.2.2]
#> 
#> * Lockfile written to '/tmp/RtmpXKN45H/file26079355a7a4a/renv.lock'.
   renv::install("bioc::SummarizedExperiment")
#> Installing BiocManager [1.30.20] ...
#>  OK [linked cache in 0.13 milliseconds]
#> * Installed 1 package in 3 seconds.
#> Installing BiocGenerics [0.44.0] ...
#>  OK [linked cache in 0.11 milliseconds]
#> Installing S4Vectors [0.36.2] ...
#>  OK [linked cache in 0.11 milliseconds]
#> Installing IRanges [2.32.0] ...
#>  OK [linked cache in 0.092 milliseconds]
#> Installing bitops [1.0-7] ...
#>  OK [linked cache in 0.096 milliseconds]
#> Installing RCurl [1.98-1.10] ...
#>  OK [linked cache in 0.14 milliseconds]
#> Installing GenomeInfoDbData [1.2.9] ...
#>  OK [linked cache in 0.14 milliseconds]
#> Installing GenomeInfoDb [1.34.9] ...
#>  OK [linked cache in 0.11 milliseconds]
#> Installing matrixStats [0.63.0] ...
#>  OK [linked cache in 0.098 milliseconds]
#> Installing MatrixGenerics [1.10.0] ...
#>  OK [linked cache in 0.095 milliseconds]
#> Installing DelayedArray [0.24.0] ...
#>  OK [linked cache in 0.12 milliseconds]
#> Installing zlibbioc [1.44.0] ...
#>  OK [linked cache in 0.12 milliseconds]
#> Installing XVector [0.38.0] ...
#>  OK [linked cache in 0.1 milliseconds]
#> Installing GenomicRanges [1.50.2] ...
#>  OK [linked cache in 0.17 milliseconds]
#> Installing Biobase [2.58.0] ...
#>  OK [linked cache in 0.097 milliseconds]
#> Installing SummarizedExperiment [1.28.0] ...
#>  OK [linked cache in 0.11 milliseconds]
#> * Installed 15 packages in 8.9 seconds.

Created on 2023-03-07 with reprex v2.0.2

Standard output and standard error
The following package(s) were not installed successfully:

	[SummarizedExperiment]: package 'SummarizedExperiment' is not available

You may need to manually download and install these packages.

The following package(s) will be updated in the lockfile:

# GitHub =============================
- renv   [* -> rstudio/renv@HEAD]

Warning message:
In in_dir(input_dir(), expr) :
  You changed the working directory to /tmp/RtmpXKN45H/file26079355a7a4a (probably via setwd()). It will be restored to /tmp/Rtmplh5kah/reprex-25b5657a3ad1-next-esok. See the Note section in ?knitr::knit
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 Patched (2022-11-10 r83330)
#>  os       Ubuntu 20.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US:en
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/Los_Angeles
#>  date     2023-03-07
#>  pandoc   2.12 @ /home/zhian/anaconda3/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version   date (UTC) lib source
#>  P BiocManager   1.30.20   2023-02-24 [?] CRAN (R 4.2.2)
#>  R cli           3.6.0     <NA>       [?] <NA>
#>  R digest        0.6.31    <NA>       [?] <NA>
#>  R evaluate      0.20      <NA>       [?] <NA>
#>  R fastmap       1.1.1     <NA>       [?] <NA>
#>  R fs            1.6.1     <NA>       [?] <NA>
#>  R glue          1.6.2     <NA>       [?] <NA>
#>  R htmltools     0.5.4     <NA>       [?] <NA>
#>  R knitr         1.42      <NA>       [?] <NA>
#>  R lifecycle     1.0.3     <NA>       [?] <NA>
#>  R magrittr      2.0.3     <NA>       [?] <NA>
#>  R purrr         1.0.1     <NA>       [?] <NA>
#>  R R.cache       0.16.0    <NA>       [?] <NA>
#>  R R.methodsS3   1.8.2     <NA>       [?] <NA>
#>  R R.oo          1.25.0    <NA>       [?] <NA>
#>  R R.utils       2.12.2    <NA>       [?] <NA>
#>  P renv          0.17.0-26 2023-03-07 [?] Github (rstudio/renv@9b48ce7)
#>  R reprex        2.0.2     <NA>       [?] <NA>
#>  R rlang         1.0.6     <NA>       [?] <NA>
#>  R rmarkdown     2.20      <NA>       [?] <NA>
#>  R sessioninfo   1.2.2     <NA>       [?] <NA>
#>  R styler        1.9.1     <NA>       [?] <NA>
#>  R vctrs         0.5.2     <NA>       [?] <NA>
#>  R withr         2.5.0     <NA>       [?] <NA>
#>  R xfun          0.37      <NA>       [?] <NA>
#>  R yaml          2.3.7     <NA>       [?] <NA>
#> 
#>  [1] /tmp/RtmpXKN45H/file26079355a7a4a/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /tmp/RtmpXKN45H/file26079355a7a4a/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72
#> 
#>  P ── Loaded and on-disk path mismatch.
#>  R ── Package was removed from disk.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

the available packages database returned by r-universe doesn't include some fields; e.g. "OS_type", and we're failing to account for that.

I'm wondering, if it's possible for @jeroen to address this in the R-universe, will the R-universe repos work with {renv} 0.17.0?

@zkamvar zkamvar closed this as completed Mar 7, 2023
@kevinushey
Copy link
Collaborator

This is a bug in renv -- I plan to push a patch release of renv soon, as sure as I'm confident these issues are all resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants