rstudio / blogdown

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

Blogdown Files not Showing in R Studio #711

Closed BB1464 closed 2 years ago

BB1464 commented 2 years ago

When I try to create my first personal website using blogdown in Rstudio, I start with File -> New Project -> New Directory ->website using blogdown with the default theme. Then I used to run blogdown::serve_site() from the console and I get the site for R markdown. Unfortunately, when I open index.rmd from content, the codes are empty to edit to my own code. not only index.rmd but all others like about, config.yaml... are not shown from the editor window. When I click it, pops up with an empty script window.

I think this might be an Issue with the new version of R 4.2, but However, it works when I try it using File -> Reopen with Encoding -> UTF-8, Please how can I resolve this issue ?

cderv commented 2 years ago

Unfortunately I cannot reproduce on my side so I don't think this is an issue with RStudio IDE or R 4.2.0 directly. it could come from your environment.

Can you give use some details about that ? Which OS ? Which version of tools are you using ? RStudio ? packages ? Hugo ?

When I click it, pops up with an empty script window.

What does it looks like exactly ? Can you share a screenshot ?

However, it works when I try it using File -> Reopen with Encoding -> UTF-8, Please how can I resolve this issue ?

Maybe something related to encoding 🤔 Does it happens only with Hugo and blogdown or also for other type of project ?

BB1464 commented 2 years ago

It happens with Hugo and Blogdown but on Quarto or my other script everything work fine. Please find below my session info and attached screenshot with a post that is not coming up but when I open it with encoding (UTF-8) everything will work fine.

R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 [2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] knitr_1.39 magrittr_2.0.3 munsell_0.5.0
[4] cowplot_1.1.1 tidyselect_1.1.2 colorspace_2.0-3
[7] R6_2.5.1 rlang_1.0.2 fastmap_1.1.0
[10] fansi_1.0.3 dplyr_1.0.9 tools_4.2.0
[13] grid_4.2.0 gtable_0.3.0 xfun_0.31
[16] utf8_1.2.2 DBI_1.1.2 cli_3.3.0
[19] htmltools_0.5.2 ellipsis_0.3.2 assertthat_0.2.1
[22] yaml_2.3.5 digest_0.6.29 tibble_3.1.7
[25] lifecycle_1.0.1 crayon_1.5.1 ggplot2_3.3.6.9000 [28] purrr_0.3.4 tidyr_1.2.0 vctrs_0.4.1
[31] glue_1.6.2 evaluate_0.15 rmarkdown_2.14
[34] blogdown_1.10.1 compiler_4.2.0 pillar_1.7.0
[37] scales_1.2.0 generics_0.1.2 pkgconfig_2.0.3
2022-06-02

cderv commented 2 years ago

You are not using the default theme in your screenshot as you described but academic blog. Are you using hugo-academic ?

What is the hugo version you are using ? blogdown::hugo_version() ?

Can you also print out the file content from R console ?

xfun::read_utf8("index.Rmd") # use path to your file 

readLines("index.Rmd")

Is the file really empty when you open it in another editor ?

BB1464 commented 2 years ago

Yes I am using hugo academic, sorry I did not state that initially.

The version of my hugo is: ‘0.100.0’

xfun::read_utf8("index.Rmd") gives the following output below:

[1] "---" "site: blogdown:::blogdown_site" [3] "---"

When I open the file in another editor it will show the content that are in the file

cderv commented 2 years ago

xfun::read_utf8("index.Rmd") gives the following output below:

I meant the index.Rmd file in your screenshot, the one in post folder

When I open the file in another editor it will show the content that are in the file

So file is not empty, but when you open in RStudio IDE the file appears to be empty ? If so, it seems like an issue regarding the IDE not blogdown directly. I just want to confirm that

BB1464 commented 2 years ago

Please find below the output when I run xfun::read_utf8('index.Rmd')

[1] "---"
[2] "title: Functional Programming with Purrr" [3] "author: Oluwafemi"
[4] "date: '2022-06-02'"
[5] "slug: function"
[6] "categories:"
[7] " - Functional Programming"
[8] "tags: []"
[9] "subtitle: ''"
[10] "summary: ''"
[11] "authors: []"
[12] "lastmod: '2022-06-02T16:59:21+01:00'"
[13] "featured: no"
[14] "image:"
[15] " caption: ''"
[16] " focal_point: ''"
[17] " preview_only: no"
[18] "projects: []"
[19] "---"

cderv commented 2 years ago

So the file is definitely not empty.

when you open in RStudio IDE the file appears to be empty ?

Is this the thing that really happen ? When you run blogdown::serve_site(), does the website appear ok ?

If so, then I think this would be an issue with RStudio IDE, and not the R package blogdown. It is just strange that this happens only with a blog project.

If this is related to encoding as you think, then we should look closer to the encoding of the saved files. You can look at them in VScode or notepad++ (or probably other editor) to see which encoding they are. But usually, encoding issue creates weird characters not blank files.

BB1464 commented 2 years ago

When I run blogdown serve_site() the site appears Ok, I think the issues has to be encoding.

cderv commented 2 years ago

Can you fill an issue in the RSTUDIO IDE repo then ?

If you manage to find the root of the issue (make your example without blogdown for example), this would probably help. Otherwise, anything than can help make it reproducible will be best!

BB1464 commented 2 years ago

Ok, Thank you, I will do that.

cderv commented 2 years ago

@BB1464 I think you could have encountered this bug: https://community.rstudio.com/t/rstudio-2022-02-3-has-been-released-windows-users-should-update/138993/2

https://twitter.com/rstudiotips/status/1532775784632356865?s=20&t=pgEDRouxA-OymcxIEc9roA

You should update RStudio IDE to last released version as this is a major bug

BB1464 commented 2 years ago

@cderv thank you for your help, I really appreciate. I will update my R Studio IDE to the last release version.