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

shiny_prerendered documents execute in wrong environment #1124

Closed
wch opened this Issue Aug 23, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@wch
Copy link
Contributor

wch commented Aug 23, 2017

For example, this document will read args and output_file from the environment created by shiny_prerendered_html()'s invocation.

---
title: "Untitled"
output: html_document
runtime: shiny_prerendered

---

```{r}
args
output_file
```

The result looks like this:

image

The culprit is this new.env():
https://github.com/rstudio/rmarkdown/blob/6def14c/R/shiny_prerendered.R#L125

Perhaps it should have parent=globalenv()?

@jjallaire jjallaire closed this in 7e7f503 Aug 23, 2017

yihui added a commit that referenced this issue Oct 19, 2017

Fix #1162: use parent.frame() of run() instead of new.env() inside rm…
…arkdown_shiny_server() to evaluate code chunks (#1165)

* Fix #1162: use parent.frame() of run() instead of new.env() inside rmarkdown_shiny_server() to evaluate code chunks

This should be the correct fix to #619, instead of the PR #624, which introduced new.env().

* use parent.frame() instead of new.env() for shiny_prerendered docs (fixes #1124)

* tweak news

yihui added a commit that referenced this issue Nov 10, 2017

Fix #1193: adjust the environment in which R code chunks in Shiny Rmd…
… are evaluated

The environment should not be simply render_args$envir (which defaults to parent.frame() in render()), because Shiny's input/output/session variables are not available in this environment. We have to create a new environment with the environment of Shiny's server function environment being its parent, and render_args$envir being its grandparent environment.

All previous relevant cases #1162, #619, and #1124 have been tested.

Also closes #1194.

yihui added a commit that referenced this issue Nov 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.