rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.74k stars 331 forks source link

Issue (humbug?) with the new_post_addin() #685

Closed maelle closed 2 years ago

maelle commented 2 years ago

Minimal website https://github.com/maelle/blogdowntest

If I try to create a .Rmd or .Rmarkdown post with the addin, using the newsletter archetype, I get an error.

> blogdown:::new_post_addin()

Listening on http://127.0.0.1:6541
Avis : Error in new_content: Failed to create the file 'post/2022-03-02-try/index.Rmd'.
  9: shiny::runApp
  8: shiny::runGadget
  7: eval
  6: eval
  5: sys.source
  2: source_addin [/home/maelle/Documents/ropensci/WEBSITE/blogdown/R/addin.R#1]
  1: blogdown:::new_post_addin [/home/maelle/Documents/ropensci/WEBSITE/blogdown/R/addin.R#6]
Backtrace:
  1. blogdown:::new_post_addin()
  2. blogdown:::source_addin("new_post.R")
       at blogdown/R/addin.R:6:17
  5. base::sys.source(...)
       at blogdown/R/addin.R:1:15
     ...
  9. shiny::runApp(app, port = port, launch.browser = viewer)
 16. shiny:::serviceApp()
 17. httpuv::service(timeout)
 18. later::run_now(timeoutMs/1000, all = FALSE)
 19. later:::execCallbacks(timeoutSecs, all, loop$id)

Backtrace:
  1. blogdown:::new_post_addin()
  2. blogdown:::source_addin("new_post.R")
       at blogdown/R/addin.R:6:17
  5. base::sys.source(...)
       at blogdown/R/addin.R:1:15
     ...
  9. shiny::runApp(app, port = port, launch.browser = viewer)
 16. shiny:::serviceApp()
 17. httpuv::service(timeout)
 18. later::run_now(timeoutMs/1000, all = FALSE)
 19. later:::execCallbacks(timeoutSecs, all, loop$id)

Creating an Rmd with the default archetype, or a .md, seems to work.

R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS, RStudio 2022.2.0.350

Locale:
  LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C               LC_TIME=fr_FR.UTF-8       
  LC_COLLATE=fr_FR.UTF-8     LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
  LC_PAPER=fr_FR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
  LC_TELEPHONE=C             LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

Package version:
  base64enc_0.1.3      blogdown_1.7.3       bookdown_0.24        bslib_0.3.1.9000    
  cachem_1.0.6         digest_0.6.29        evaluate_0.14        fastmap_1.1.0       
  fs_1.5.2             glue_1.6.1           graphics_4.1.0       grDevices_4.1.0     
  highr_0.9            htmltools_0.5.2.9000 httpuv_1.6.5         jquerylib_0.1.4     
  jsonlite_1.7.3       knitr_1.37           later_1.3.0          magrittr_2.0.2      
  memoise_2.0.1.9000   methods_4.1.0        mime_0.12            promises_1.2.0.1    
  R6_2.5.1             rappdirs_0.3.3       Rcpp_1.0.8           rlang_1.0.1         
  rmarkdown_2.11.15    sass_0.4.0           servr_0.24           stats_4.1.0         
  stringi_1.7.6        stringr_1.4.0        tinytex_0.36         tools_4.1.0         
  utils_4.1.0          xfun_0.29            yaml_2.2.2          

Hugo version: 0.89.0

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:

maelle commented 2 years ago

Noting that while the Rmd is not created, a .md is created in the right folder (but not with the right medata).

maelle commented 2 years ago

The problem is in new_content() where when using the archetype, path2 is e.g. post/2022-02-05-try2 instead of post/2022-02-05-try2/index.md

maelle commented 2 years ago

Rather in what's passed to new_content()

yihui commented 2 years ago

Thanks for the report! I just identified the problem in Hugo: https://github.com/gohugoio/hugo/issues/9157 (it was a regression that affected three versions of Hugo, including 0.89.0, which you were using in your project).

I think your fix #686 is correct (which revealed a blogdown bug), and will merge it soon.

maelle commented 2 years ago

I just identified the problem in Hugo: https://github.com/gohugoio/hugo/issues/9157 (it was a regression that affected three versions of Hugo, including 0.89.0, which you were using in your project).

Interesting!! I didn't even think about why that part didn't work.

yihui commented 2 years ago

I was quite puzzled in the beginning, because in theory the newly created file should be identified from Hugo's message, but Hugo was silent for some reason. Then my buggy plan B failed, too, and you correctly identified that bug.