rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more
http://rstudio.github.io/rsconnect/
131 stars 80 forks source link

from-source packages reported during deploy when unrelated to project #915

Closed aronatkins closed 10 months ago

aronatkins commented 1 year ago
> rsconnect::writeManifest("~/dev/rstudio/standalone/rmarkdown")
ℹ Capturing R dependencies with renv
The following package(s) were installed from sources, but may be available from the following remotes:

- rsconnect  [rstudio/rsconnect]

Would you like to use these remote sources for these packages?
See 'snapshot.inference' in ?renv::config for more details.
Otherwise, these packages will be recorded with an unknown source.

Allow renv to update the remote sources for these packages? [Y/n]: 

The target directory contains an rsconnect folder, which renv sees as needing the rsconnect package.

aronatkins commented 1 year ago

This may be happening any time the GitHub version of rsconnect is in use.

td <- tempfile()
dir.create(td)
fn <- file.path(td, "index.Rmd")
writeLines(c("hello, markdown"), fn)
rsconnect::writeManifest(td)

This is enough to trigger the warning from renv.

aronatkins commented 1 year ago

When running these commands, my working directory was the rsconnect directory, not a content directory.

hadley commented 1 year ago

Possibly a similar case to https://github.com/rstudio/renv/issues/1469, but for snapshot()?

hadley commented 1 year ago

Also worth noting that I see this for every (?) dev package I have installed, so I don't think it's related to rsconnect. And I don't think it's related to package dependencies, since nothing should depend on S7:

The following package(s) were installed from sources, but may be available from the following remotes:

- admiral       [pharmaverse/admiral]
- bigrquery     [r-dbi/bigrquery]
- bookdown      [rstudio/bookdown]
- cmdstanr      [stan-dev/cmdstanr]
- cocktails     [hadley/cocktails]
- codebook      [rubenarslan/codebook]
- downlit       [r-lib/downlit]
- flexsurv      [chjackson/flexsurv-dev]
- freshr        [shawnlinxl/freshr]
- gtreg         [shannonpileggi/gtreg]
- hockeyR       [danmorse314/hockeyR]
- htmlbook      [hadley/htmlbook]
- inti          [flavjack/inti]
- log4r         [johnmyleswhite/log4r]
- multidplyr    [tidyverse/multidplyr]
- partialised   [UchidaMizuki/partialised]
- pryr          [hadley/pryr]
- rATTAINS      [mps9506/rATTAINS]
- rsconnect     [rstudio/rsconnect]
- S7            [rconsortium/OOP-WG]
- tidyjson      [colearendt/tidyjson]
- tidytemplate  [tidyverse/tidytemplate]
- TreeTools     [ms609/TreeTools]
- tsibble       [tidyverts/tsibble]
- urlchecker    [r-lib/urlchecker]
- wakefield     [trinker/wakefield]

And the manifest doesn't end up including any of these packages.

hadley commented 1 year ago

Argh, I've re-installed renv (from CRAN) and rsconnect (from source), and tweaked the reprex to run in a non-interactive environment, and now it seems ok:

td <- tempfile()
dir.create(td)
fn <- file.path(td, "index.Rmd")
writeLines(c("hello, markdown"), fn)

callr::r(\() rsconnect::writeManifest(), wd = td, show = TRUE)
#> ℹ Capturing R dependencies with renv
#> ✔ Found 31 dependencies
#> NULL

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

aronatkins commented 1 year ago

Possible workaround:

Sys.setenv(RENV_CONFIG_SNAPSHOT_INFERENCE = "false")
rsconnect::writeManifest(td)

Unfortunately, if a package is missing (rmarkdown, for example), we are prompted to install some unknown set of packages:

> Sys.setenv(RENV_CONFIG_SNAPSHOT_INFERENCE = "false")
> rsconnect::writeManifest(td)
ℹ Capturing R dependencies with renv
What do you want to do? 

1: Snapshot, just using the currently installed packages.
2: Install the packages, then snapshot.
3: Cancel, and resolve the situation on your own.

Selection: 3
- Operation canceled.
aronatkins commented 1 year ago

Workaround: disable renv valiation:

Sys.setenv(RENV_CONFIG_SNAPSHOT_VALIDATE = "false")
rsconnect::writeManifest(td)
#> ℹ Capturing R dependencies with renv
#> ✔ Found 31 dependencies
aronatkins commented 1 year ago

The renv:::renv_snapshot_preflight function is called only when snapshot validation is enabled, and its call to renv:::renv_snapshot_preflight_check_sources only happens when interactive().

aronatkins commented 1 year ago

I am also no longer seeing the What do you want to do? prompt. Could the CRAN mirror propagation to cran.rstudio.com be in play?

aronatkins commented 1 year ago

Filed https://github.com/rstudio/renv/issues/1559 to track the problem with rsconnect-from-source.

aronatkins commented 1 year ago

The formatting of the message has changed with the latest GitHub version of renv:

> rsconnect::writeManifest(td)
ℹ Capturing R dependencies with renv
The following package(s) were installed from sources, but may be available from the following remotes:
- rsconnect  [rstudio/rsconnect]
Would you like to use these remote sources for these packages?
See 'snapshot.inference' in ?renv::config for more details.
Otherwise, these packages will be recorded with an unknown source.

Allow renv to update the remote sources for these packages? [Y/n]: n

✔ Found 31 dependencies
kevinushey commented 1 year ago

@aronatkins: how are you installing the development version of rsconnect?

aronatkins commented 1 year ago

@kevinushey - rsconnect was installed using the IDE "Install" button in the Build pane. Normal package development workflow. The same warning would happen for renv if it was installed using the IDE, as well.

hadley commented 10 months ago

With a local version of rsconnect and latest CRAN renv, I now see:

td <- tempfile()
dir.create(td)
fn <- file.path(td, "index.Rmd")
writeLines(c("hello, markdown"), fn)
rsconnect::writeManifest(td)
#> ℹ Capturing R dependencies with renv
#> ✔ Found 31 dependencies

Created on 2023-10-26 with reprex v2.0.2

So maybe this is fixed now?

aronatkins commented 10 months ago

So maybe this is fixed now?

Seems like it. I've not recently hit this.