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

wflow_build with local=TRUE doesn't leave objects in global namespace #53

Closed
JohnReid opened this issue Jul 14, 2017 · 6 comments
Closed
Assignees
Labels

Comments

@JohnReid
Copy link

After calling wflow_build('Singh-DeLorean.Rmd', local=TRUE), I expected to have all the objects created in the Rmarkdown file available in my global namespace. This doesn't seem to be the case. Are they somewhere else? What does local=TRUE actually do? I'm not using RStudio, could this be the problem?

/usr/bin/pandoc +RTS -K512m -RTS Singh-DeLorean.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output Singh-DeLorean.html --smart --email-obfuscation none --standalone --section-divs --table-of-contents --toc-depth 3 --variable toc_float=1 --variable toc_selectors=h1,h2,h3 --variable toc_collapsed=1 --variable toc_smooth_scroll=1 --variable toc_print=1 --template /home/john/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --include-before-body /tmp/Rtmp8FGvZY/rmarkdown-str41fb391d3e6b.html --variable navbar=1 --variable body_padding=51 --variable header_padding=56 --variable 'theme:cosmo' --include-in-header /tmp/Rtmp8FGvZY/rmarkdown-str41fb3f160d34.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-after-body include/footer.html

Output created: ../docs/Singh-DeLorean.html
Summary from wflow_build

Settings:
  seed: 12345

The following were built locally in the current R session:

../docs/Singh-DeLorean.html
> dl
Error: object 'dl' not found
> ls()
character(0)
@pcarbo
Copy link
Member

pcarbo commented Jul 14, 2017

@JohnReid I can see why you would be confused by this, and @jdblischak I think we should clarify this point in the documentation. I am also thinking that this is a potentially useful feature for testing R Markdown documents when building one of them at a time (I think should be easy to implement in render_site using the default value for input argument envir?).

Function wflow_build calls render_site from the rmarkdown package with envir = new.env(). So your R Markdown script will be executed from inside a new environment, and will have no effect on the global environment.

@jdblischak will likely have more to add.

@jdblischak
Copy link
Member

Thanks for reporting this, @JohnReid. I agree with you that local = TRUE should leave the objects in the global namespace.

And @pcarbo is right, this behavior is because I pass the argument envir = new.env() to rmarkdown::render_site() (line). This is actually a remnant from before I had implemented the option to build the files externally. Setting envir = new.env() helped prevent sharing of variables across files. Since the default is to build the files externally, and local = TRUE is for debugging, it makes the most sense to build the file directly in the global environment.

I'll post to this Issue once this update has been merged into the master branch.

@jdblischak jdblischak self-assigned this Jul 14, 2017
@jdblischak jdblischak added the bug label Jul 14, 2017
@JohnReid
Copy link
Author

Great. Thanks for the quick action.

@jdblischak
Copy link
Member

@JohnReid I haven't fixed it yet so I am keeping this Issue open so that other users will see it. Once the change is made and merged into master, I'll close it.

@jdblischak jdblischak reopened this Jul 14, 2017
jdblischak added a commit that referenced this issue Jul 20, 2017
= TRUE`. This adds any objects created by the file to the global
environment and also adds any loaded packages to the search path. This
makes it more useful for debugging R Markdown files.

Fix Issue #53.
@jdblischak
Copy link
Member

@JohnReid This feature has been implemented in v0.7.0. See the release notes for other changes (most noticeably wflow_build() now runs wflow_view() automatically by default). You can upgrade to this latest release by running the following:

devtools::install_github("jdblischak/workflowr", build_vignettes = TRUE)

Please try it out and let me know if this now works as expected.

@JohnReid
Copy link
Author

Thanks for the quick response, this works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants