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

Building vignettes breaks down on Windows using rticles::jss_article if a plot is present #528

Closed
3 tasks done
GFabien opened this issue Apr 19, 2023 · 4 comments
Closed
3 tasks done

Comments

@GFabien
Copy link

GFabien commented Apr 19, 2023

Hi, first of all, thanks for the great package! It is really convenient.

We were about to submit our package to the CRAN, so we tested on different platforms and realized that devtools::build_vignettes() was not working on Windows. We managed to identify the problem. Our vignette uses rticles::jss_article as the output type. It fails as soon as there is a plot in the vignette. We looked at the generated .tex file: the default Windows path style is used (C:\foo\bar), breaking the LaTeX command displaying the figure.

This seems like an easy fix, and I would be happy to provide a PR for it, but I would need assistance finding what part of the code is responsible for that.

Reproducible example

---
documentclass: jss
author:
  - name: Foo Bar
title: "Foo"
output: rticles::jss_article
vignette: >
  %\VignetteIndexEntry{Foo}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r}
plot(1:10)
```

Running devtools::build_vignettes() produces an error with the previous vignette.

Session info

xfun::session_info()

xfun::session_info()
R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621), RStudio 2023.3.0.386

Locale:
  LC_COLLATE=French_France.utf8  LC_CTYPE=French_France.utf8    LC_MONETARY=French_France.utf8 LC_NUMERIC=C                  
  LC_TIME=French_France.utf8    

Package version:
  askpass_1.1          base64enc_0.1.3      brew_1.0.8           brio_1.1.3           bslib_0.4.2          cachem_1.0.7        
  callr_3.7.3          caret_6.0-94         class_7.3-21         cli_3.6.1            clipr_0.8.0          clock_0.6.1         
  codetools_0.2-19     colorspace_2.1-0     commonmark_1.9.0     compiler_4.2.3       cpp11_0.4.3          crayon_1.5.2        
  credentials_1.3.2    curl_5.0.0           data.table_1.14.8    desc_1.4.2           devtools_2.4.5       diagram_1.6.5       
  diffobj_0.3.5        digest_0.6.31        downlit_0.4.2        dplyr_1.1.1          e1071_1.7.13         ellipsis_0.3.2      
  evaluate_0.20        fansi_1.0.4          farver_2.1.1         fastmap_1.1.1        fontawesome_0.5.1    foreach_1.5.2       
  fs_1.6.1             future_1.32.0        future.apply_1.10.0  generics_0.1.3       gert_1.9.2           ggplot2_3.4.2       
  gh_1.4.0             gitcreds_0.1.2       globals_0.16.2       glue_1.6.2           gower_1.0.1          graphics_4.2.3      
  grDevices_4.2.3      grid_4.2.3           gtable_0.3.3         hardhat_1.3.0        highr_0.10           htmltools_0.5.5     
  htmlwidgets_1.6.2    httpuv_1.6.9         httr_1.4.5           httr2_0.2.2          ini_0.3.1            ipred_0.9-14        
  isoband_0.2.7        iterators_1.0.14     jquerylib_0.1.4      jsonlite_1.8.4       KernSmooth_2.23.20   knitr_1.42          
  labeling_0.4.2       later_1.3.0          lattice_0.20-45      lava_1.7.2.1         lifecycle_1.0.3      listenv_0.9.0       
  lubridate_1.9.2      magrittr_2.0.3       MASS_7.3-58.2        Matrix_1.5-3         memoise_2.0.1        methods_4.2.3       
  mgcv_1.8.42          mime_0.12            miniUI_0.1.1.1       ModelMetrics_1.2.2.2 munsell_0.5.0        nlme_3.1-162        
  nnet_7.3-18          numDeriv_2016.8.1.1  openssl_2.0.6        parallel_4.2.3       parallelly_1.35.0    pillar_1.9.0        
  pkgbuild_1.4.0       pkgconfig_2.0.3      pkgdown_2.0.7        pkgload_1.3.2        plyr_1.8.8           praise_1.0.0        
  prettyunits_1.1.1    pROC_1.18.0          processx_3.8.1       prodlim_2023.03.31   profvis_0.3.7        progressr_0.13.0    
  promises_1.2.0.1     proxy_0.4.27         ps_1.7.5             purrr_1.0.1          R6_2.5.1             ragg_1.2.5          
  rappdirs_0.3.3       rcmdcheck_1.4.0      RColorBrewer_1.1.3   Rcpp_1.0.10          recipes_1.0.5        rematch2_2.1.2      
  remotes_2.4.2        reshape2_1.4.4       rlang_1.1.0          rmarkdown_2.21       roxygen2_7.2.3       rpart_4.1.19        
  rprojroot_2.0.3      rstudioapi_0.14      rticles_0.24.9       rversions_2.1.2      sass_0.4.5           scales_1.2.1        
  sessioninfo_1.2.2    shape_1.4.6          shiny_1.7.4          sourcetools_0.1.7.1  splines_4.2.3        SQUAREM_2021.1      
  stats_4.2.3          stats4_4.2.3         stringi_1.7.12       stringr_1.5.0        survival_3.5-3       sys_3.4.1           
  systemfonts_1.0.4    testthat_3.1.7       textshaping_0.3.6    tibble_3.2.1         tidyr_1.3.0          tidyselect_1.2.0    
  timechange_0.2.0     timeDate_4022.108    tinytex_0.45         tools_4.2.3          tzdb_0.3.0           urlchecker_1.0.1    
  usethis_2.1.6        utf8_1.2.3           utils_4.2.3          vctrs_0.6.1          viridisLite_0.4.1    waldo_0.4.0         
  whisker_0.4.1        withr_2.5.0          xfun_0.38            xml2_1.3.3           xopen_1.0.0          xtable_1.8-4        
  yaml_2.3.7           zip_2.3.0

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rticles'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rticles').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@cderv
Copy link
Collaborator

cderv commented Apr 19, 2023

I believe this is not an issue with jss_article() - this is broader and will happen with any vignettes built with rmarkdown engine with format not embeding the image (as html_vignette() or other format is doing.

This is directly related to rstudio/rmarkdown#2024 where fig.path will be set to absolute path when outpur_dir is used. and IMO is an hidden issue with vignette since knitr 1.27 as the vignette engine is using output.dir yihui/knitr@b80ece1

Definitely something we should fix somehow.

As a workaround for you need, you can customize the fig path in a setup chunk

```{r include = FALSE}
knitr::opts_chunk$set(
  fig.path = "figures/"
)
```

This will correctly use relative paths, and should not be a problem. Though you need to pay attention to chunk name for figures if you have several Rmds and one global folder, or use something like fig.path = "figures/foo-"

I'll add more insight in rstudio/rmarkdown#2024 based on this report as I see vignettes issue more clearly now.

Thanks for the report. i'll close as we need to handle this in rmarkdown


BTW about vignette building

See this discussion r-lib/devtools#2488 where devtools::build_vignettes() is no more recommended.
The recommended workflow is now the following: https://r-pkgs.org/vignettes.html#sec-vignettes-workflow-writing

This doesn't solve the issue but could be helpful with resources handling.

@GFabien
Copy link
Author

GFabien commented Apr 19, 2023

Thank you! The workaround works like a charm!

@cderv
Copy link
Collaborator

cderv commented Apr 19, 2023

Great. You just need to make sure that resources in vignettes/ are correctly included for your R CMD CHECK to pass.
Useful R-HUB blog post

HTML vignettes does not have such issue because images are embeded inside the HTML and not are external resources

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants