rstudio / learnr

Interactive Tutorials with R Markdown
https://pkgs.rstudio.com/learnr
Apache License 2.0
710 stars 240 forks source link

Cannot include child RMarkdown documents #408

Open KatherineCox opened 4 years ago

KatherineCox commented 4 years ago

If I try to include a child document, it works the first time a tutorial is run, but then errors the second time because it cannot find the child document

Example

Learnr tutorial:

---
title: "Test Inserting a Child RMarkdown Document"
output: learnr::tutorial
runtime: shiny_prerendered
---

```{r setup, include=FALSE}
library(learnr)
knitr::opts_chunk$set(echo = FALSE)

#### Child document:

I'm a child!

Here's some R code

summary(cars)

#### First run:
<img width="1207" alt="Screen Shot 2020-07-29 at 9 32 57 AM" src="https://user-images.githubusercontent.com/13210811/88808368-cb985a80-d180-11ea-8824-8c4812a84b71.png">

#### Second run:

Quitting from lines 14-15 (/var/folders/y3/png21yc50g5g041t82_6c0100000gp/T//RtmpAFpkzA/www/child.Rmd) Error in file(con, "r") : cannot open the connection Calls: ... process_tangle.block -> lapply -> FUN -> knit -> readLines -> file In addition: Warning message: In file(con, "r") : cannot open file '/var/folders/y3/png21yc50g5g041t82_6c0100000gp/T//RtmpAFpkzA/www/child.Rmd': No such file or directory Execution halted


### Describe the problem in detail

It seems like when the progress is stored, the child document isn't copied over in a way that makes it accessible to the tutorial.

I can also get it to work again by reseting the tutorial
- delete the code chunk that pulls in the child document
- run the tutorial
- click "Start Over"
- add back the code chunk that pulls in the child document
- run the tutorial

This will again work once, and then not work the second time.

#### Context

I have some boilerplate content that I want to stick at the front of several tutorials (instructions for students, logo, some metadata) and it would be convenient to maintain that in a single location rather than in each of the tutorials.  I'm not trying to run learnr questions or exercises in the child document (although composable tutorials would be lovely someday).

### System details

Output of `sessioninfo::session_info()()`:

─ Session info ──────────────────────────────────────────────────────────── setting value
version R version 3.6.1 (2019-07-05) os macOS Catalina 10.15.5
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2020-07-29

─ Packages ──────────────────────────────────────────────────────────────── package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0) backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0) cli 2.0.1 2020-01-08 [1] CRAN (R 3.6.0) crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0) digest 0.6.21 2019-09-20 [1] CRAN (R 3.6.0) evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0) fansi 0.4.0 2018-10-05 [1] CRAN (R 3.6.0) fastmap 1.0.1 2019-10-08 [1] CRAN (R 3.6.0) glue 1.4.1 2020-05-13 [1] CRAN (R 3.6.2) htmltools 0.5.0 2020-06-16 [1] CRAN (R 3.6.2) htmlwidgets 1.5.1 2019-10-08 [1] CRAN (R 3.6.0) httpuv 1.5.2 2019-09-11 [1] CRAN (R 3.6.0) jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.0) knitr 1.25 2019-09-18 [1] CRAN (R 3.6.0) later 1.1.0.1 2020-06-05 [1] CRAN (R 3.6.2) learnr 0.10.1 2020-02-13 [1] CRAN (R 3.6.0) magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0) markdown 1.1 2019-08-07 [1] CRAN (R 3.6.0) mime 0.7 2019-06-11 [1] CRAN (R 3.6.0) packrat 0.5.0 2018-11-14 [1] CRAN (R 3.6.0) promises 1.1.1 2020-06-09 [1] CRAN (R 3.6.2) R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.0) Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.0) rlang 0.4.2 2019-11-23 [1] CRAN (R 3.6.0) rmarkdown 2.3 2020-06-18 [1] CRAN (R 3.6.2) rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0) rsconnect 0.8.15 2019-07-22 [1] CRAN (R 3.6.0) rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.0) sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0) shiny 1.5.0 2020-06-23 [1] CRAN (R 3.6.2) withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0) xfun 0.14 2020-05-20 [1] CRAN (R 3.6.2) xtable 1.8-4 2019-04-21 [1] CRAN (R 3.6.0) yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)

[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

dtkaplan commented 4 years ago

I'm not able to reproduce this problem.

─ Session info ──────────────────────────────────────────────────────────────────────────── setting value version R version 3.6.3 (2020-02-29) os macOS Catalina 10.15.6 system x86_64, darwin15.6.0 ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz America/Denver date 2020-07-29

─ Packages ──────────────────────────────────────────────────────────────────────────────── package * version date lib source

assertthat 0.2.1 2019-03-21 [2] CRAN (R 3.6.0)

backports 1.1.8 2020-06-17 [1] CRAN (R 3.6.3)

broom 0.7.0 2020-07-09 [1] CRAN (R 3.6.2)

checkmate 2.0.0 2020-02-06 [1] CRAN (R 3.6.0)

cli 2.0.2 2020-02-28 [1] CRAN (R 3.6.0)

colorspace 1.4-1 2019-03-18 [2] CRAN (R 3.6.0)

crayon 1.3.4.9000 2020-05-06 [1] Github (r-lib/crayon@dcf6d44)

crosstalk 1.1.0.1 2020-03-13 [1] CRAN (R 3.6.0)

curl 4.3 2019-12-02 [1] CRAN (R 3.6.0)

data.table 1.12.8 2019-12-09 [1] CRAN (R 3.6.0)

digest 0.6.25 2020-02-23 [1] CRAN (R 3.6.0)

distill 0.7 2019-05-03 [2] CRAN (R 3.6.0)

dplyr * 1.0.0 2020-05-29 [1] CRAN (R 3.6.2)

ellipsis 0.3.1 2020-05-15 [1] CRAN (R 3.6.2)

evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0)

fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.0)

farver 2.0.3 2020-01-16 [1] CRAN (R 3.6.0)

fastmap 1.0.1 2019-10-08 [2] CRAN (R 3.6.0)

generics 0.0.2 2018-11-29 [2] CRAN (R 3.6.0)

ggdendro 0.1-20 2016-04-27 [2] CRAN (R 3.6.0)

ggforce 0.3.2 2020-06-23 [1] CRAN (R 3.6.2)

ggformula * 0.9.4 2020-03-04 [1] CRAN (R 3.6.0)

ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 3.6.2)

ggrepel 0.8.2 2020-03-08 [1] CRAN (R 3.6.0)

ggstance * 0.3.4 2020-04-02 [1] CRAN (R 3.6.0)

glue 1.4.1 2020-05-13 [1] CRAN (R 3.6.2)

gridExtra 2.3 2017-09-09 [2] CRAN (R 3.6.0)

gtable 0.3.0 2019-03-25 [2] CRAN (R 3.6.0)

hms 0.5.3 2020-01-08 [1] CRAN (R 3.6.0)

htmltools 0.5.0 2020-06-16 [1] CRAN (R 3.6.3)

htmlwidgets 1.5.1 2019-10-08 [2] CRAN (R 3.6.0)

httpuv 1.5.4 2020-06-06 [1] CRAN (R 3.6.2)

httr 1.4.2 2020-07-20 [1] CRAN (R 3.6.2)

jsonlite 1.7.0 2020-06-25 [1] CRAN (R 3.6.2)

knitr 1.29 2020-06-23 [1] CRAN (R 3.6.2)

labeling 0.3 2014-08-23 [2] CRAN (R 3.6.0)

later 1.1.0.1 2020-06-05 [1] CRAN (R 3.6.2)

lattice * 0.20-38 2018-11-04 [2] CRAN (R 3.6.3)

lazyeval 0.2.2 2019-03-15 [2] CRAN (R 3.6.0)

leaflet 2.0.3 2019-11-16 [1] CRAN (R 3.6.0)

learnr 0.10.1.9004 2020-06-16 [1] Github (dtkaplan/learnr@c76684b)

lifecycle 0.2.0 2020-03-06 [1] CRAN (R 3.6.0)

lubridate 1.7.9 2020-06-08 [1] CRAN (R 3.6.2)

magrittr 1.5 2014-11-22 [2] CRAN (R 3.6.0)

markdown 1.1 2019-08-07 [1] CRAN (R 3.6.0)

MASS 7.3-51.5 2019-12-20 [2] CRAN (R 3.6.3)

Matrix * 1.2-18 2019-11-27 [2] CRAN (R 3.6.3)

metR 0.7.0 2020-04-10 [1] CRAN (R 3.6.2)

mime 0.9 2020-02-04 [2] CRAN (R 3.6.0)

MMAC 0.1.2 2018-07-05 [1] CRAN (R 3.6.0)

mosaic * 1.7.0 2020-05-18 [1] CRAN (R 3.6.2)

mosaicCalc 0.5.1.9000 2020-06-16 [1] Github (ProjectMOSAIC/mosaicCalc@eb3d4cf) mosaicCore 0.6.0 2018-06-24 [2] CRAN (R 3.6.0)

mosaicData * 0.18.0 2020-05-15 [1] CRAN (R 3.6.2)

munsell 0.5.0 2018-06-12 [2] CRAN (R 3.6.0)

packrat 0.5.0-25 2019-11-14 [1] Github (rstudio/packrat@448aafd)

pillar 1.4.6 2020-07-10 [1] CRAN (R 3.6.2)

pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0)

plotly 4.9.2.1 2020-04-04 [1] CRAN (R 3.6.2)

polyclip 1.10-0 2019-03-14 [1] CRAN (R 3.6.0)

promises 1.1.1 2020-06-09 [1] CRAN (R 3.6.2)

purrr 0.3.4 2020-04-17 [1] CRAN (R 3.6.2)

R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0)

Rcpp 1.0.5 2020-07-06 [1] CRAN (R 3.6.2)

readr 1.3.1 2018-12-21 [2] CRAN (R 3.6.0)

rlang 0.4.7 2020-07-09 [1] CRAN (R 3.6.2)

rmarkdown 2.3 2020-06-18 [1] CRAN (R 3.6.2)

rprojroot 1.3-2 2018-01-03 [2] CRAN (R 3.6.0)

rsconnect 0.8.16 2019-12-13 [1] CRAN (R 3.6.0)

rstudioapi 0.11 2020-02-07 [2] CRAN (R 3.6.0)

scales 1.1.1 2020-05-11 [1] CRAN (R 3.6.2)

sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0)

shiny 1.5.0 2020-06-23 [1] CRAN (R 3.6.2)

stringi 1.4.6 2020-02-17 [1] CRAN (R 3.6.0)

stringr 1.4.0 2019-02-10 [2] CRAN (R 3.6.0)

tibble 3.0.3 2020-07-10 [1] CRAN (R 3.6.2)

tidyr 1.1.0 2020-05-20 [1] CRAN (R 3.6.2)

tidyselect 1.1.0 2020-05-11 [1] CRAN (R 3.6.2)

tweenr 1.0.1 2018-12-14 [1] CRAN (R 3.6.0)

vctrs 0.3.2 2020-07-15 [1] CRAN (R 3.6.3)

viridisLite 0.3.0 2018-02-01 [2] CRAN (R 3.6.0)

withr 2.2.0 2020-04-20 [1] CRAN (R 3.6.2)

xfun 0.16 2020-07-24 [1] CRAN (R 3.6.2)

xtable 1.8-4 2019-04-21 [2] CRAN (R 3.6.0)

yaml 2.2.1 2020-02-01 [1] CRAN (R 3.6.0)

KatherineCox commented 4 years ago

@dtkaplan thanks for looking into this. I'm happy to follow any suggestions to try to track it down. It's happening consistently for me.

gadenbuie commented 3 years ago

@KatherineCox I can reproduce your error when the child chunk option is formatted like child = c("www/child.R"). If you remove the c(), the document will work again: child = "www/child.R".