-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
opts_chunk$get("output.dir") contains a mangled file path? #1471
Comments
I'm not sure, either, but this is an undocumented option, and I don't recommend that you use it: https://yihui.name/knitr/options/ |
We'll stop using it, but it seems like its a bug in knitr anyway... |
Okay, I'll investigate it when I have time. Thanks for the report! |
Here is how to reproduce and why we get this behavior dir.create(tmp_dir <- tempfile(pattern = "R-3.2.3"))
tmp_dir
#> [1] "C:\\Users\\chris\\AppData\\Local\\Temp\\Rtmp8AKB5r\\R-3.2.382703ad777be"
owd <- setwd(tmp_dir)
# let's reproduce
gert::git_clone("https://github.com/mtmorgan/outputdir")
xfun::Rcmd(c("build", "outputdir"))
xfun::Rcmd(c("check", "outputdir_1.10.0.tar.gz"))
# the folder with _ is here
fs::dir_tree("..", recurse = FALSE)
#> ..
#> +-- file82702e9a265a
#> +-- file827077bf6bcb.dll
#> +-- R-3.2.382703ad777be
#> \-- R-3_2_382703ad777be
folder <- dir("..", "R-3_2_3")
fs::dir_tree(file.path("..", folder), recurse = TRUE)
#> ../R-3_2_382703ad777be
#> \-- outputdir_Rcheck
#> \-- vign_test
#> \-- outputdir
#> \-- vignettes
#> +-- Xunnamed-chunk-1-1.pdf
#> \-- Xunnamed-chunk-1-1.png
unlink(file.path("..", folder), recursive = T)
# it comes indeed from knitr, you'll get a warning if you knit the file
knitr::knit("outputdir/vignettes/main.Rnw")
#> processing file: outputdir/vignettes/main.Rnw
#> output file: main.tex
#> [1] "main.tex"
#> Warning message:
#>In (if (out_format(c("latex", "sweave", "listings"))) sanitize_fn else paste0)(path, :
#> dots in figure paths replaced with _ ("C:/Users/chris/AppData/Local/Temp/RtmpofFca4/R-3_2_37f3059ef625f/Xunnamed-chunk-1")
# specifically this function is called by fig.path to
# explicitly replace dots by _
knitr:::sanitize_fn("R-3.2.2")
#> Warning in knitr:::sanitize_fn("R-3.2.2"): dots in figure paths replaced with _
#> ("R-3_2_2")
#> [1] "R-3_2_2"
setwd(owd)
unlink(tmp_dir) As shown above this is from internal The side effect is what you observe. @yihui investigation done. It seems by design. Should we keep this open as a bug or close as won't fix ? |
@cderv Thanks for the investigation! So the problem is that |
I don't think we have something to do here. This does not seems to be a very common issue, but it is good to have it documented. I don't really know about the dot issue in LaTeX. |
This repo https://github.com/mtmorgan/outputdir has an Rnw vignette. The vignette has a main document and a child document. The code chunk to include the child document includes fig.path that references
opts_chunk$get("output.dir")
. When built and run in a directory that contains a '.', e.g.,the check, specifically the step
* checking re-building of vignette outputs ... OK
creates a new directory hierarchy where the '.' inR-3.4.2
is changed to '_',R-3_4_2
:which is very undesirable. I can't tell whether this is an unfortunate name collision, bad form in the original package, or a bug.
The text was updated successfully, but these errors were encountered: