I am having the exact same issue as what was reported here:
As in the prior example, the r markdown window is completely blank and nothing happens. The failure of the button happens with the default markdown documents. However, rmarkdown::render() does work.
It runs in the console but does not produce the markdown document. In the console it says (note the name of my Rmd file is trial.Rmd):
output file: trial.md
[1] "trial.md"
In contrast, when I run
rmarkdown::render("trial.Rmd")
In the console it returns:
output file: trial.knit.md
Output created: trial.docx
And the markdown document is created
That's interesting. I didn't expect render() to retain the intermediate markdown file. By default the option clean is TRUE.
So knit('trial.Rmd') doesn't produce a markdown file. I wonder what the important difference is between when render calls knit and the call we previously made.
Check that it's not the output path.
Perhaps it's an issue with the default output file path that render is working around for knit. Try knitting the following document and specify an output path to knit() that doesn't have spaces or non-ascii characters.
Glad the first shot worked. Tells us there's something with the default path knit tries on your system that causes the failure. The default output path is calculated from the input file and working directory.
Non-solutions
Trying to set the working directory with setwd() before you use the knit button is not going to work as the button starts a new child process that is not inheriting your working environment.
You might also be tempted to try mucking about with the knitr::opts$set('output.dir' = "/path/to/some/directory") , but that will be overwritten by this line.
Band Aids
Move the project
The easiest fix might be to move the project to a less offensive directory.
Undocumented knit hook
On a document by document basis, you can change the function the knit button invokes. As mentioned in this rmarkdown issue and a SO post, there exists the knit hook for the front matter of Rmarkdown documents. It has to be a function written on one line, but you could use it to hard code the ouput path, and it should replace the call the knit button makes. It's not a great fix, but it appears to get the job done.
What a helpful response. Thanks for laying out my options so clearly.
As far as moving the output file, there isn't something peculiar about my directory. It doesn't work regardless of where I put it. Example directories are simple ones like: "C:/Users/Documents/" or "C:/Users/Desktop/" Not sure what could be offensive about that directory.
Your knit hook example isn't working for me. If I paste that directly into a new markdown document and replace '/your/alternate/path' with 'C:/Users/Desktop' nothing happens when I click the Knit button. It still seems dead.
After fiddling around some, there is no console output with knit(), but with render() before creating the output document the console says:
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS trial.utf8.md --to docx --from markdown+autolink_bare_uris+tex_math_single_backslash+smart --output trial.docx --highlight-style tango --lua-filter "C:/Users/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua"
Interesting. That is the expected logging from render. Knitr emits .md files. Rmarkdown uses knitr to create markdown then calls an external program, pandoc, to create the target output format.
Summary of observations
Calling render from the console produces expected target format file (e.g. trial.html)
Calling knit and specifying the output param from the console produced the expected .md file
Invoking knit button produces no files and not output in the R markdown tab of Rstudio.
Specifying the previous knit hook and then invoking the knit button produces not files nor output.
Moving the proejct directory does not affect the knit button behavior.
Is that all correct?
Experiment with knit hook.
Let's check if that's even working. That knit hook is supposed to replace the whole kit and caboodle of generating intermediate files and the final output. So lets have it ignore all the params and barf out a simple text file. Try the following and see if it actually produces a text file where you expect.
The simplified knit hook does not produce anything.
Regarding your summary of observations, I might just add that Calling knit and specifying the output param from the console produced the expected .md file and the expected target format file. Without specifying the output param only the .md file is created.
Changing the location of the project, and ostensibly the default path passed to knit doesn't work.
Short of setting up a VM to replicate this problem, I'm out of things to try to sort out what's going awry.
Rstudo Add-in
Writing an add-in to replicate functionality that should be working for you is the last thing I can think of that would allow you to have some shortcut to build your documents. I'd fork the example project and modify the shortcuts to run a function that calls knit or render with options that are known good for you.
Submit a bug report to Rstudio
Put in a bug report for the rstudio repo on github. If possible, create a project with a minimal example that reproduces the issue for you. Include such details as the path on your machine you're running the project from, and the libraries and versions you're using devtools::session_info or utils::sessionInfo()
Similar to issue 5179 which needed a reproducible example supplied.