rstudio / blogdown

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

Rmd post can't be rendered (Error: X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12 could not be loaded) #696

Closed amarakon closed 2 years ago

amarakon commented 2 years ago

I created a new site with blogdown::new_site() and previewed it with blogdown::serve_site(). The default site should have three posts, one from 2020, one from 2016, and one from 2015, https://bookdown.org/yihui/blogdown/a-quick-example.html#fig:lithium. The 2020 one is written in a file called index.Rmd. When I view my website, it only shows the 2016 and 2015 posts. It doesn't show any posts written in Rmd files. How do I fix this?

yihui commented 2 years ago

Could you read and follow the issue guide exactly to provide all the required information? As requested, please do not ignore or delete the issue guide in your post, otherwise it is usually hard for us to help you. Thanks!

amarakon commented 2 years ago

Okay, I will provide more information. I ran blogdown::check_site() and it gave me this output:

> blogdown::check_site()
― Running a series of automated checks for your blogdown website project...
--------------------------------------------------------------------------------
○ A successful check looks like this.
● [TODO] A check that needs your attention looks like this.
| Let's check out your blogdown site!
--------------------------------------------------------------------------------
― Checking config.yaml
| Checking "baseURL" setting for Hugo...
● [TODO] Update "baseURL" to your actual URL when ready to publish.
| Checking "ignoreFiles" setting for Hugo...
○ "ignoreFiles" looks good - nothing to do here!
| Checking setting for Hugo's Markdown renderer...
○ All set! Found the "unsafe" setting for goldmark.
― Check complete: config.yaml

― Checking .gitignore
● [TODO] .gitignore was not found. You may want to add this.
― Checking Hugo
| Checking Hugo version...
○ Found Hugo. You are using Hugo 0.97.1.
| Checking .Rprofile for Hugo version used by blogdown...
○ blogdown is using Hugo 0.97.1 to build site locally.
― Check complete: Hugo

― Checking netlify.toml...
○ Found HUGO_VERSION = 0.97.1 in [build] context of netlify.toml.
| Checking that remote & local Hugo versions match...
○ It's a match! Local and remote Hugo versions are identical (0.97.1).
| Checking that Netlify & local Hugo publish directories match...
○ Good to go - blogdown and Netlify are using the same publish directory: public
― Check complete: netlify.toml

― Checking content files
| Checking for validity of YAML metadata in posts...
○ All YAML metadata appears to be syntactically valid.
| Checking for previewed content that will not be published...
○ Found 0 files with future publish dates.
○ Found 0 files marked as drafts.
| Checking your R Markdown content...
● [TODO] Found 1 R Markdown file to render:

  content/post/2020-12-01-r-rmarkdown/index.Rmd

  To render a file, knit or use blogdown::build_site(build_rmd = 'newfile')
○ All R Markdown output files are up to date with their source files.
| Checking for .html/.md files to clean up...
○ Found 0 duplicate .html output files.
○ Found 0 incompatible .html files to clean up.
| Checking for the unnecessary 'content/' directory in theme...
○ Great! Your theme does not contain the content/ directory.
― Check complete: Content

I think the most important part is where it said "Fount 1 R Markdown file to render". That is exactly the R Markdown file that is not rendering and not previewing when using blogdown::serve_site(). In this output, it also told me "To render a file, knit or use blogdown::build_site(build_rmd = 'newfile')". So I ran the command blogdown::build_site(build_rmd = 'newfile'). Here is the output:

> blogdown::build_site(build_rmd = 'newfile')
Rendering content/post/2020-12-01-r-rmarkdown/index.Rmd... Quitting from lines 30-37 (index.Rmd)
Error in text.default(1.1 * P$x, 1.1 * P$y, labels[i], xpd = TRUE, adj = ifelse(P$x <  :
  X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12 could not be loaded
Calls: local ... eval_with_user_handlers -> eval -> eval -> pie -> text -> text.default
Execution halted
Error: Failed to render content/post/2020-12-01-r-rmarkdown/index.Rmd
Execution halted

Here is the output of xfun::session_info('blogdown'):

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Gentoo GNU/Linux

Locale:
  LC_CTYPE=en_CA.utf8       LC_NUMERIC=C
  LC_TIME=en_CA.utf8        LC_COLLATE=en_CA.utf8
  LC_MONETARY=en_CA.utf8    LC_MESSAGES=C
  LC_PAPER=en_CA.utf8       LC_NAME=C
  LC_ADDRESS=C              LC_TELEPHONE=C
  LC_MEASUREMENT=en_CA.utf8 LC_IDENTIFICATION=C

Package version:
  base64enc_0.1.3  blogdown_1.9     bookdown_0.26    bslib_0.3.1
  digest_0.6.29    evaluate_0.15    fastmap_1.1.0    fs_1.5.2
  glue_1.6.2       graphics_4.1.2   grDevices_4.1.2  highr_0.9
  htmltools_0.5.2  httpuv_1.6.5     jquerylib_0.1.4  jsonlite_1.8.0
  knitr_1.38       later_1.3.0      magrittr_2.0.3   methods_4.1.2
  mime_0.12        promises_1.2.0.1 R6_2.5.1         rappdirs_0.3.3
  Rcpp_1.0.8.3     rlang_1.0.2      rmarkdown_2.13   sass_0.4.1
  servr_0.24       stats_4.1.2      stringi_1.7.6    stringr_1.4.0
  tinytex_0.38     tools_4.1.2      utils_4.1.2      xfun_0.30
  yaml_2.3.5

Hugo version: 0.97.1

Finally, you can view my files at https://github.com/Amarakon55/amarakon.com.

yihui commented 2 years ago

X11 font -adobe-helvetica-%s-%s---%d-------*, face 1 at size 12 could not be loaded

I don't think this has anything to do with blogdown per se. There seems to be something broken with your R installation. You may google for that error message. I'm not familiar with Gentoo Linux, so I can't really help much here. Sorry.

amarakon commented 2 years ago

I couldn't find many people with the same issue. To verify that it is indeed a problem with my R installation, can you clone https://github.com/Amarakon55/amarakon.com, then run blogdown::check_site() and blogdown::build_site(build_rmd = 'newfile') and blogdown::serve_site()? If it works properly, you shouldn't get the font error and you should see the 2020 R Markdown post when previewing the site.

yihui commented 2 years ago

Your repo at https://github.com/Amarakon55/amarakon.com doesn't contain any Rmd posts (but only .md posts). That said, I've tested sites with blogdown::new_site() many times before and have never run into this problem.

The first result from my google search is https://stat.ethz.ch/pipermail/r-help//2016-October/442326.html But again, I have no experience with Gentoo Linux, and can't help you here. I recommend that you seek help from an R mailing list or Stack Overflow. If you don't need the plot in that Rmd post, you can delete that code chunk, and the post should be correctly rendered.

amarakon commented 2 years ago

For some reason, I have an Rmd post but git is not tracking it. You are right that on GitHub, there are only md posts, not Rmd posts. But on my local computer, I have an Rmd post. Here is a screenshot: https://imgur.com/vqVkn1q

For some reason, git is not tracking the 2020 Rmd post. If I change the file extension from .Rmd to .rmd, git tracks it. I updated the repository and now you should see the R Markdown post. Even if I change the .md file from a Markdown post to a .Rmd file (the contents of the file are still the same), the post is no longer visible.

This means that for whatever reason, blogdown is just ignoring R Markdown files even if they're valid. Perhaps it's this in config.yaml?:

ignoreFiles:
  - \.Rmd$

There is a Gentoo package called adobe-fonts-100dpi which includes Adobe Helvetiva, but that doesn't fix the X11 font issue. I posted a Stack Overflow question: https://stackoverflow.com/questions/71919138/blogdown-r-markdown-blog-post-doesnt-work

yihui commented 2 years ago

It's correct to ignore .Rmd in config.yaml. The Git issue is irrelevant (blogdown doesn't care if the Rmd file is under version control or not).

As I replied above, your problem is this error from base R, which I don't know how to fix:

X11 font -adobe-helvetica-%s-%s---%d-------*, face 1 at size 12 could not be loaded

amarakon commented 2 years ago

You're right, that is the problem. I paid close attention to the error message, and I found this:

Quitting from lines 30-37 (index.Rmd)

So I checked lines 30-37:

```{r pie, fig.cap='A fancy pie chart.', tidy=FALSE}
par(mar = c(0, 1, 0, 1))
pie(
  c(280, 60, 20),
  c('Sky', 'Sunny side of pyramid', 'Shady side of pyramid'),
  col = c('#0292D8', '#F7EA39', '#C4B632'),
  init.angle = -50, border = NA
)
\```

It's a code chunk. Once I removed that code chunk, everything worked perfectly. I could build my site, and I could preview my site. The issue is now solved. Thanks so much for your help. I'm closing this issue.