-
-
Notifications
You must be signed in to change notification settings - Fork 977
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
PDF document fails to compile when output file argument contains absolute path with tilde in Windows #2556
Comments
I can't run your example on Windows, because windows does not allow me to create a file with > temp_rmd
[1] "C:\\Users\\chris\\AppData\\Local\\Temp\\Rtmp6nVDJU/VERY_L~1/test.Rmd"
> writeLines("---\ntitle: 'Test report'\n---\n\ntest report", temp_rmd)
Error in `file()`:
! impossible d'ouvrir la connexion
Run `rlang::last_trace()` to see where the error occurred.
Message d'avis :
Dans file(con, "w") :
impossible d'ouvrir le fichier 'C:\Users\chris\AppData\Local\Temp\Rtmp6nVDJU/VERY_L~1/test.Rmd' : No such file or directory Does the reprex shared above it working for you ? (first part of it)
Does this happens only when you create some scripting around It seems on windows, when using normalize, it will only works when the path exists. > xfun::normalize_path(dirname(temp_report))
[1] "C:/Users/chris/AppData/Local/Temp/Rtmp6nVDJU/VERY_LONG_LONG_LONG_PATH"
> xfun::normalize_path(temp_report)
[1] "C:/Users/chris/AppData/Local/Temp/RTC9FB~1/VERY_LONG_LONG_LONG_PATH/report.pdf" See the difference above. Second path does not exist yet, and is passed through So maybe this is why the path is not correctly transformed before running LaTeX. (LaTeX won't handle short path windows syntax) |
I don't know if this has changed, but this is definitely the problem it seems. We should probably normalize Line 498 in 3d99b8e
using a wrapper that does unsure that shortpathname are normalized; Otherwise, we need to patch only the LaTeX rendering here Lines 974 to 996 in 3d99b8e
So that it ensures that the input tex path and others paths are normalized correctly before LaTeX rendering. @yihui any thoughts ? |
@cderv sorry, there was an error in the reprex. I fixed it in my initial post. Does it work for you now? The reprex should now hopefully demonstrate that it will also happen when the directory already exists. Thanks for the quick follow-up. See below the output of
In a different Windows machine the error did not happen, because I had a shorter username, and a TEMP path without tilde. I can work around the problem now (use a relative path for |
yes thanks a lot for the report ! This is definitely an issue, and a case we want to handle ! This will be fix - just need to decide the scope of this. Short path on Windows should work with most tools - just not LaTeX. 😞 |
Either way seems to be okay to me, but perhaps we should normalize the paths only if they are absolute paths? |
Oh that makes sense. Thanks for reminding me this ! |
The tilde abbreviation of a folder name can (apparently) happen automatically in Windows.
I noticed it because I created an absolute file path for the output PDF file in the temporary folder from windows, for use in unit tests.
The temporary folder file path will contain a tilde abbreviation if the Windows user name is long (for example, "C:/Users/Johnny with Long Name" will be abbreviated to "C:/Users/JOHNNY~1").
The problem only occurs with creating PDF documents, when attempting to convert the intermediate latex document to PDF.
See reprex below:
EDIT: fixed reprex
Output results:
Error: LaTeX failed to compile *****\AppData\Local\Temp\Rtmp2ttLaR/VERY_L~1/report.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
tex log created:
Session Info
R version 4.4.0 (2024-04-24 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 11 x64 (build 22631) Locale: LC_COLLATE=English_Germany.utf8 LC_CTYPE=English_Germany.utf8 LC_MONETARY=English_Germany.utf8 LC_NUMERIC=C LC_TIME=English_Germany.utf8Package version:
base64enc_0.1.3 bslib_0.7.0 cachem_1.0.8 cli_3.6.2 digest_0.6.35 evaluate_0.23
fastmap_1.1.1 fontawesome_0.5.2 fs_1.6.4 glue_1.7.0 graphics_4.4.0 grDevices_4.4.0
highr_0.10 htmltools_0.5.8.1 jquerylib_0.1.4 jsonlite_1.8.8 knitr_1.46 lifecycle_1.0.4
memoise_2.0.1 methods_4.4.0 mime_0.12 R6_2.5.1 rappdirs_0.3.3 rlang_1.1.3
rmarkdown_2.26.2 sass_0.4.9 stats_4.4.0 tinytex_0.50 tools_4.4.0 utils_4.4.0
xfun_0.43 yaml_2.3.8
Pandoc version: 3.1.11
Checklist
When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:
formatted your issue so it is easier for us to read?
included a minimal, self-contained, and reproducible example?
pasted the output from
xfun::session_info('rmarkdown')
in your issue?upgraded all your packages to their latest versions (including your versions of R, the RStudio IDE, and relevant R packages)?
installed and tested your bug with the development version of the rmarkdown package using
remotes::install_github("rstudio/rmarkdown")
?The text was updated successfully, but these errors were encountered: