yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.36k stars 873 forks source link

autodep regression by #2321 #2344

Open heavywatal opened 1 month ago

heavywatal commented 1 month ago

The option autodep=TRUE does not work since #2321 even with the simplest example as follows:

```{r, setup}
knitr::opts_chunk$set(cache = TRUE)
knitr::opts_chunk$set(autodep = TRUE)
x = 1
y = 10 * x
y

Modifying `x` in `src` chunk should invalidate the cache of the dependent chunk `dst`, but is ignored in the latest version. I have tried different versions with `pak::pkg_install("yihui/knitr")`. Here are the results:

- OK: `"yihui/knitr@v1.45"`
- OK: `"yihui/knitr@74bcff85455a9f92a3099abecba1a8d70ab0cfa4"` 74bcff85
- NG: `"yihui/knitr@f36e52cf39abba3be261e8e957c92587c63fa599"` f36e52cf
- NG: `"yihui/knitr@v1.46"`
- NG: `"yihui/knitr"` HEAD

xfun::session_info('knitr') R version 4.4.0 (2024-04-24) Platform: x86_64-apple-darwin20 Running under: macOS Sonoma 14.5

Locale: C / en_US.UTF-8 / C / C / C / C

Package version: evaluate_0.23 grDevices_4.4.0 graphics_4.4.0 highr_0.11 knitr_1.46.5 methods_4.4.0 stats_4.4.0 tools_4.4.0 utils_4.4.0 xfun_0.44 yaml_2.3.8



<!--
Please keep the below portion in your issue. Your issue will be closed if any of the boxes is not checked (i.e., replace `[ ]` by `[x]`). In certain (rare) cases, you may be exempted if you give a brief explanation (e.g., you are only making a suggestion for improvement). Thanks!
-->

---

By filing an issue to this repo, I promise that

- [x] I have fully read the issue guide at https://yihui.org/issue/.
- [x] I have provided the necessary information about my issue.
    - If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    - If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included `xfun::session_info('knitr')`. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: `remotes::install_github('yihui/knitr')`.
    - If I have posted the same issue elsewhere, I have also mentioned it in this issue.
- [x] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.
heavywatal commented 1 month ago

FYI, adding cache-globals does not help invalidation.

```{r, dst2}
#| cache-globals:
#|   - x
z = 100 * x
z
yihui commented 1 month ago

@knokknok @atusy Could you take a look? Thanks!

atusy commented 1 month ago

I will

knokknok commented 1 month ago

Don't you need an initial dep_auto() to set-up the system?