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
Issue with knitting R Markdown documents #2344
Comments
|
From all those error, I would say rmarkdown or RStudio IDE is kind of detecting you are in a bookdown project.
Are you working in a project ? Or are you working in a default working directory with all those files around ? Is |
|
I am working in an RStudio Project, not in the default working directory. But despite that, the _main.Rmd file is saved in the default working directory instead of the project's directory. |
This means it is something related to RStudio IDE. what is the function called when you are clicking the knit / render button ? |
|
When I press the knit button, the function being called is rmarkdown::render_site. This is what I get in the "render" tab After your message, I uninstalled the RStudio IDE, and reinstalled it again. But still the problem continues. |
|
So, as a workaround, I added one more line in the YAML header of the .Rmd file After this, I could compile it properly. But it also means that I will have to add this line to all the R Markdown documents now onwards, unless and until the behavior of the Knit button changes. I will have to add this line even to the old R markdown documents that I have prepared earlier. How can I change the default behavior of the Knit button now? |
|
Could you share the whole project? You can compress it into a zip archive and upload here. It's hard to tell what's wrong without a reproducible example. |
|
TeXLive.zip |
|
That's really odd. I can't reproduce the problem, and can't think of a reason why RStudio would treat any of your Rmd file as a bookdown project. What is your project option |
|
The Project Build Tools: (None) |
|
That's correct. Then I really don't know how your RStudio ended up in that weird state. Do you have anything suspicious in your Perhaps the last suggestion that I could give is reset RStudio: https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-State If that doesn't work, I'll be out of ideas. |
|
I don't save .RData file. And I haven't created .Rprofile file either. |
|
On further experiments, when I uninstalled bookdown package, and then tried knitting the document through "Knit" button, it knits properly, but I get an error:
At this time, I can see in the "Render" tab that the knit button is taking rmarkdown::render function to knit the document. I can knit in all the three formats (word, html and pdf). |
|
Can you run rmarkdown::site_generator("path/to/file")
rmarkdown::site_generator(".")I believe this is what RStudio IDE is using to decide if it is a website project. Basically, it would been seen as a bookdown project if you have a We recently had issues with our internal
rmarkdown:::proj_root("path/to/file", "^index.R?md$", "^\\s*site:.*::.*$")I wonder if what happens is that your current project is located in a subfolder somehow of another folder/project that would have and Thank you. |
|
You are probably right. I don't fully understand the output of these functions you have suggested, but I have still followed your suggestion. I am attaching the results here. |
|
Yes this is it. The results you shared shows that a book project website is detected, and that is why the IDE is behaving as in a book project. It seems it comes from Can you check that ? If that is correct, is that That being said, I don't think we have a correct behavior here. We should not probably check for website project that far up the current folder. I am thinking we should stop at the root of the RStudio project (when @yihui does it feel off to you too ? |
|
Yes, there is an index.Rmd file in that folder. I deleted the _main.Rmd from E:/Maulik?Projects, and moved the index.Rmd file (along with its other associated files) to a new folder. After that, I restarted RStudio. Now the Knit button works properly. |
|
So that was the culprit ! Glad we found it! I'll leave this issue open until we decide if this needs to be improved (which I do) and how. Thanks a lot for the report! |
|
Thanks for your continuous support. Let me know if you decide to improve it. I would like to participate in its testing. |
@cderv That makes sense to me. |
@bhattmaulik if would help if you can test #2345 ? remotes::install_github("rstudio/rmarkdown#2345") |
Previously, it was looking in all the folders until main root of the tree. This was causing issue in RStudio IDE where a website project was detected incorrectly for a non-site project included into a subfolder of a site project. See #2344 for context.
|
@bhattmaulik this is now in dev version of rmarkdown remotes::install_github("rstudio/rmarkdown")Thanks! |
|
I just checked it. I had both the files (index.Rmd and _main.Rmd) in the global root directory, and yet the Rmd file inside an RStudio project knitted a pdf file without any trouble. Thank You! |
I am facing a strange issue in last 2-3 days. I am unable to knit any .Rmd file to any format (HTML/PDF/Word). First, I create an RStudio Project. Within the RStudio Project, from RStudio File Menu>New File > R Markdown, I choose any of the three output formats. I simply save the document without making any changes in the defaults in the Rmd file. Then I press the "knit" button in RStudio. I get the following error while rendering it.
Isn't _main.Rmd supposed to be in bookdown? How can I get this error while knitting a single R Markdown file? Moreover, this _main.Rmd file is saved in a different location - it's the default working directory (while not in a project).
Irrespective of this, if I try to knit it again, I get the error message
So, again it confirms that the underlying function is from bookdown instead of R Markdown.
I have updated all the relevant software - downloaded knitr, R Markdown and bookdown from github. I have also installed latest daily build of tinytex (using tinytex::install_prebuilt("TinyTeX"))and RStudio. The session info is as follows;
The text was updated successfully, but these errors were encountered: