-
Notifications
You must be signed in to change notification settings - Fork 0
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
Bug 18226 - Leakage between vignettes #12
Comments
SummaryIssue: When two vignettes are built, the function defined in the first vignette can persist to the second one. Likely cause: When vignettes (in the same directory) are built using AnalysisI traced the issue in R-4.2.1 as follows:
I believe the use of Thoughts
It is unclear what the intended behavior is. If vignettes of the same directory are considered as one long vignette split into small pieces, then persisting the namespace may make sense. Otherwise, if vignettes are considered self-contained documents, then this could be a bug. In terms of risk, between the users assuming the namespace persistence and the ones who do not, I think it is easier for the former group to find out when persistence is not available (since the latter vignettes using the namespace would just fail) than the latter group to find out the persistence is implicitly there all the time. In any case, we may not need to speculate what the intended behavior is, but rather to support both - keeping the existing behavior as the default for backward compatibility and allowing that to be overridden when needed.
It may not be necessary to start a new R session to build a vignette (assuming that is what Duncan suggested).
Not sure. It does not seem to require much change to the code, so maybe this can be changed in the short term. Thanks. |
Thank you for your contribution. I think evaluation in the global environment should be considered a feature of Sweave() (and similarly knitr::knit(), by default), as it allows running the vignette in an interactive session and easily inspect/work with the results. As discussed in the R-devel thread, one option for (a) the current R CMD build vignette strategy does not seem to be documented (maybe someone can confirm this), and the impact of such a change should be small. Of course, changes to the build procedure need great care as they cannot be verified by simply rechecking existing source builds from CRAN for example. |
Thank you for the fast response and for explaining the rationale! Confirming my understanding:
I checked Manual - R-devel - Writing R extensions - section 1.4 - writing package vignettes and didn't see the strategy documented. The four points related the R CMD build are:
So perhaps the next thing to explore is to see roughly how much change it would incur matching R CMD check? P.S. Sorry I did not realise the post was a thread, and I overlooked the responses. Felt a bit silly duplicating the effort, but it has also been a lot of fun seeing firsthand how Sweave builds the document line-by-line! For future reference, this links to the last response of the thread which contains all the key discussion. |
But one issue is that if the vignettes are built in different orders they won't be the same. I think DM is really talking about that this can happen unintentionally. So the question is whether we should allow it to happen intentionally. |
Some of these issues came up during discussion in the first session. Personally, I think vignettes should be able to run in a clean session (with packages involved and data available), primarily because I think that should be true of all dynamic documents that haven't been linked together explicitly via, e.g., an explicitly declared dependency structure (a la make). Barring that, however, it does seem to me that if vignettes are going to be run in the same session, there should be a way to declare a collate order for them, similar to what we do for R files in |
Thanks a lot for the input. @elinw I agree, and to add to what you said, I think it makes a difference to know whether the behavior is by design or not, because if the persistence is by design, then what needs to be changed is the documentation, not the code; the different results caused by the different vignettes order (unexpected by users) is a problem communicating the right behavior to the users, not a problem in the implementation. @gmbecker Great point on declaring a collate order. At the moment, I think the collate order follows the order returned from For everyone's information, after investigating a bit further, I notice:
I don't think
To move forward with this issue, I think we need to settle whether there should be one / two behaviors for the R CMD build process (knowing that |
https://bugs.r-project.org/show_bug.cgi?id=18226
Do you agree this a bug?
Does the fix proposed by Duncan Murdoch make sense (probably yes, but good to consider ourselves)?
How likely is it this can be changed in the short term? If not likely, what would the staging of this change look like?
The text was updated successfully, but these errors were encountered: