bookdown icon indicating copy to clipboard operation
bookdown copied to clipboard

Can not knit Rmarkdown file to html or pdf document after installing bookdown package

Open shafayetShafee opened this issue 2 years ago • 7 comments

When I tried to knit the following file, It worked as intended. I got the pdf output (even for output: html_document, I got the html file).

---
title: "Test"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

### Text 1
            
some more text.....
         
### Text 2
        
some more text..

But I noticed the following text in my Rstudio console

Error in loadNamespace(x) : there is no package called ‘bookdown’

I am really confused by this. Because I haven't used any function from bookdown here. Everytime I knit the Rmd file, I get the desired output file but this line is growing in my console. So then, I installed bookdown (from CRAN). And then nothing works. I get the following error message in the Render panel inside Rstudio.

Error in if (grepl("(html|gitbook|bs4)", format)) return("html") : argument is of length zero Calls: <Anonymous> ... <Anonymous> -> <Anonymous> -> render_book -> target_format Execution halted

This error persists even after I have installed the development version of bookdown from Github. Now If I remove the bookdown package (using remove.packages("bookdown")), then again knitting to pdf or html document works but get the following line in the console

Error in loadNamespace(x) : there is no package called ‘bookdown’

Here is my session info

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044), RStudio 2022.7.1.554

Locale:
  LC_COLLATE=English_United States.utf8 
  LC_CTYPE=English_United States.utf8   
  LC_MONETARY=English_United States.utf8
  LC_NUMERIC=C                          
  LC_TIME=English_United States.utf8    

Package version:
  base64enc_0.1.3 bookdown_0.27.3 bslib_0.4.0    
  cachem_1.0.6    cli_3.3.0       compiler_4.2.1 
  digest_0.6.29   evaluate_0.15   fastmap_1.1.0  
  fs_1.5.2        glue_1.6.2      graphics_4.2.1 
  grDevices_4.2.1 highr_0.9       htmltools_0.5.3
  jquerylib_0.1.4 jsonlite_1.8.0  knitr_1.39     
  magrittr_2.0.3  memoise_2.0.1   methods_4.2.1  
  R6_2.5.1        rappdirs_0.3.3  rlang_1.0.4    
  rmarkdown_2.14  rstudioapi_0.13 sass_0.4.2     
  stats_4.2.1     stringi_1.7.8   stringr_1.4.0  
  tinytex_0.40    tools_4.2.1     utils_4.2.1    
  xfun_0.31       yaml_2.3.5

shafayetShafee avatar Aug 09 '22 06:08 shafayetShafee

I'm having the same problem...

fdepaolis avatar May 22 '23 17:05 fdepaolis

This may be an RStudio IDE problem. Is the Rmd document inside an RStudio project? Is there a _bookdown.yml or index.Rmd?

yihui avatar May 22 '23 19:05 yihui

@yihui, actually its been while and I do not remember correctly whether I was working within a specific Rstudio Project or there was an index.Rmd file in the same folder, but I am certain there was no _bookdown.yml. And I have not used {rmarkdown} or {bookdown} since then (Actually moved to Quarto).

However, I have just installed bookdown and tried to knit a fresh Rmd file, and am having no errors. Everything is running fine now (feeling sort of guilty that couldn't reproduce my own issued problem).

But probably @fdepaolis could provide a reproducible example along with additional info required.

shafayetShafee avatar May 22 '23 20:05 shafayetShafee

In my case, I'm working within a project and a .Rmd file...just a regular output: pdf_document; I had to reinstall RStudio to get rid of the bookdown settings. I can get the .pdf document just fine, but still get the 'error about bookdown not being installed'...and I don't plan to re-install bookdown...it messed up everything (which is odd because everything was working fine yesterday...go figure)

fdepaolis avatar May 22 '23 22:05 fdepaolis

You can check Tools -> Project Options -> Build Tools and make sure it's not set to Website. You shouldn't need to reinstall anything.

yihui avatar May 23 '23 02:05 yihui

…it was already set to ‘none’…but then again, several settings are bypassed. For instance, the setting ‘knit to directory’ is set to ‘project’ and still it’s knitted to the document directory…yes, very annoying…

Fernando DePaolis, Ph.D. Associate Professor Middlebury Institute of International Studieshttp://www.middlebury.edu/institute at Monterey

[Sent from Outlook for Mac –MacBook Pro] My working hours (US Pacific time zone) may not be your working hours. Please do not feel obligated to respond outside your normal work hours, unless otherwise indicated.

From: Yihui Xie @.> Date: Monday, May 22, 2023 at 7:15 PM To: rstudio/bookdown @.> Cc: DePaolis, Fernando @.>, Mention @.> Subject: Re: [rstudio/bookdown] Can not knit Rmarkdown file to html or pdf document after installing bookdown package (Issue #1367)

You can check Tools -> Project Options -> Build Tools and make sure it's not set to Website.

— Reply to this email directly, view it on GitHubhttps://github.com/rstudio/bookdown/issues/1367#issuecomment-1558394539, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AALU4GHAMHI5KXIWQPWFXETXHQMSDANCNFSM557RPRZA. You are receiving this because you were mentioned.Message ID: @.***>

fdepaolis avatar May 23 '23 15:05 fdepaolis

That's really odd. Then I have no idea why it happens (not sure if you could make a minimal reproducible example by compressing the project into a zip file and upload it here). Sorry...

yihui avatar May 23 '23 15:05 yihui