Open PromyLOPh opened 3 years ago
Hi,
It is not clear to me what you are trying to do. Can you be more precise ?
here are some information to help:
rmarkdown::run
is dedicated to render document using a shiny runtime. You can use if on a Rmd file having a shiny runtime, shiny Rmd or learnr tutorials for example. It is not made for serving a whole website.
See https://bookdown.org/yihui/rmarkdown/shiny-start.html
"To run a Shiny document in RStudio, you need to click the button “Run Document” on the editor toolbar (RStudio will automatically replace the “Knit” button with “Run Document” when it detects a Shiny document). If you do not use RStudio, or want to run the document in the R console for troubleshooting, you can call the function rmarkdown::run() and pass the filename to it."
Are you trying to use it on shiny Rmd documents ?
trying to serve the gh-pages branch of this very repository.
You mentioned this repo gh-page
branch - it contains what I believe to be a Rmarkdown website
You can't just call rmarkdown::run
on this folder. For website, there is rmarkdown::render_site()
See more about website here: https://bookdown.org/yihui/rmarkdown/rmarkdown-site.html
Also, a reminder that for questions, you can also ask on https://rstudio.community.com. It is better suited for generic question.
I am waiting for more details on your issue if there is still one, otherwise I'll close this as a question topic.
My quest is to serve all Rmd files from a subtree (i.e. directory and all subdirectories). These can be anything, from “simple” Rmarkdown files to shiny documents (using learnR). The gh-pages
branch is just a simple example of how run()
fails to work with subdirectories. There is usually no site configuration _site.yaml
, because it’s not a website, just a bunch of unrelated documents. render_site()
won’t work with interactive learnR tutorials, because it generates a static website, right?
It is not made for serving a whole website.
But the documentation clearly states “The server will render any R Markdown (.Rmd) document in dir”. I’m confused why that would not include subdirectories and would consider it a bug, because it fails to do so in very non-obvious ways (i.e. showing a blank page with no explanation whatsoever).
(I’m using rmarkdown v2.5 – sorry about the mixup.)
Sorry for the delay on this. We're going back on rmarkdown an I am looking at still opened issues.
These can be anything, from “simple” Rmarkdown files to shiny documents (using learnR).
I think your issue relates to this other one: https://github.com/rstudio/rmarkdown/issues/2037
Currently rmarkdown::run
won't be able to work with multiple shiny_prerendered documents. learnr are shiny prerendered document. This is probably due to a limitation in the current design that would need to change: https://github.com/rstudio/rmarkdown/issues/1576
The server will render any R Markdown (.Rmd) document in dir
This will apply in case of other documents or shiny document inside the directory. rmarkdown::run()
is still design to run shiny apps. It will call shiny::runApp()
to launch a local shiny server. There is no R Markdown server.
However, if you have several documents in your directory, and that you are running a document with runtime: shiny
(often index.Rmd
), you'll be able to route toward another document. This is useful for links between documents for example.
This should work for runtime: shiny
document only because the issue linked above for other.
I’m confused why that would not include subdirectories and would consider it a bug
Considering all of the above limitation, it seems indeed that this is not working with subdirectories. The page is blank because some resources are not found.
Here is a repo example: https://github.com/cderv/test-shiny-rmd
Doing
rmarkdown::run("index.Rmd")
will correctly launch the app.
The about page can be rendered (following the link) but the page in sub directories have errors loading.
JS resources are looked for in the sub directory when they are in the root dir.
So yes it seems sub directories are not supported. I don't know how popular this usage of running a shiny apps with several Rmd shiny document is.
For non Rmd shiny document, one would use rmarkdown::render_site()
or another website tools like distill or block**
It is either a path issue or specific to rmarkdown::run()
behavior.
I’m running a Rmarkdown server (v0.5.0) using
from the command line, trying to serve the
gh-pages
branch of this very repository.dir
is intentionally set to the current directory, which contains the source checkout. Now, this directory contains multiple subdirectories with different Rmd files, but only the ones in the top directory (i.e..
) are actually accessible. The problem is that the Shiny server returns HTML with relative references. For files in the root directory (for example/index.Rmd
) this is fine, but for other files (for example/demos/1-example.Rmd
) is is not. Specifically resources searched for in the directoriesshared/
andrmd_resources/
seem to prevent proper loading of documents.I would expect Rmarkdown files in the entire subtree to be accessible with the above command, disregarding their location.
Session info:
By filing an issue to this repo, I promise that
xfun::session_info('rmarkdown')
. 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('rstudio/rmarkdown')
.I understand that my issue may be closed if I don't fulfill my promises.