-
-
Notifications
You must be signed in to change notification settings - Fork 978
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
setting output_dir in render() will create absolute path for knitr fig.path #2024
Comments
I was aware of this problem long time ago, and tried to make the figure path relative since I didn't like the absolute paths, but I remember the interaction among |
Maybe we could try for a next version to improve / fix / rethink all the path interaction. I feel this is a larger work as it seems we keep fixing things here and there. I may try my idea of just setting relative path here for figure in this case, but if we agree on larger work maybe I'll wait for when I have time to tackle all this. |
Feel free to try. I don't remember what I tried exactly last time or what problem I ran into. |
Hi guys, I just found myself trapped on the same issue. Funny to see that this topic was open "recently". In my case, I am generating reports with rmarkdown with output format github_document. My directory structure is as follows: Rstudio project directory:
Example:
In order to change the output directory for the md document, I use: The problem is that this command changes the fig paths to be absolute (as opposite to relative) to my computer. Reading this thread, I used the chunk option I cannot find a solution for this... not sure if this example can assist you to figure out the problem. If I can be of any help to test something, I'd be pleased. thanks! |
@yihui as reported in rstudio/rticles#528 this in fact has a big impact on vignettes. I believe when vignettes are build, RStudio IDE will also set I don't know if this is recent or not but definitely happening. We should definitely try to find a way to improve that for next release. |
It sounds like the problem should affect all PDF vignettes that contain plots? If it is such a serious problem, I wonder why we didn't receive more reports. Anyway, it's definitely worth fixing, but it may be quite tricky... |
Yes I wondered the same. 🤔 I think it is worth looking into to see if we can something scoped to vignette at first maybe. I understand this could be quite tricky. Maybe this absolute path is not really the issue for vignette (as what happens in rstudio/rticles#528) and the issue in only on Windows environment with absolute path in |
See this reproducible example
Only difference between the two calls is setting the
output_dir
.I don't think this is expected behavior but this is what happens in
render()
output_dir
is set, it will be normalizedrmarkdown/R/render.R
Lines 336 to 342 in 4b119a9
rmarkdown/R/render.R
Lines 488 to 492 in 4b119a9
rmarkdown/R/render.R
Lines 500 to 502 in 4b119a9
fig.path
rmarkdown/R/render.R
Lines 632 to 635 in 4b119a9
Maybe in this last step we should explicitly set
fig.path
to a relative one ? Usingxfun::relative_path()
?The handling of paths in
render
is always source of unexpected behavior when one the argument is set.Related in a way to #1508
The text was updated successfully, but these errors were encountered: