I've been using RStudio/knitr to create PDFs for many months now, and I've just encountered some strange behavior today.
The first time I knit a PDF, the PDF preview window will open as usual. If I then close it, make more changes, and then re-knit it, the preview window won't open again. The pdf IS being recreated, I can open the file in a separate application and see the new changes included. It's just that the preview window in rstudio isn't opening. If I completely close and restart RStudio, then once again I'll see the preview window the first time I knit but not after that.
Trouble-shooting I've done so far:
I've gone up to the Window menu to make sure that the preview window isn't opening in some weird location/size that I'm not seeing, but it also shows that the preview window is not open.
I've double-checked the setting for "Preview in Window", it is correctly set.
I updated RStudio to the latest version (1.1.463), still happening.
I've opened old rmarkdown files from back when I didn't have this issue, and the issue persists with them too now, so it's not an issue with the new file I'm trying to knit.
The only thing I can think of is that I did upgrade my Mac to Mojave a couple weeks ago, and this is the first time I've used rstudio since (I'm a university student, upgraded my Mac over the holiday break between semesters, just using it for the first time this semester). I've searched for issues with Mojave and rstudio, and while there do seem to be some issues, I haven't seen anyone mention this. I did find one person who posted the same issue back in 2017 on stackoverflow (and here I think) but there were no responses on those posts.
I have your configuration but didn't experience the same issue. Here's what I did:
Created a new RMarkdown file with the pdf option
Knit
Saw preview
Changed the chuck with plot(pressure) to plot(cars)
Knit
Saw preview
Can you try that to eliminate Mojave/RStudio minimal issues and then post of reproducible example, called a reprex of an Rmd file that's giving your the problem?
Thanks for the reply. Did you close the preview in between steps 3 and 4? If so, then yes, when I follow those same steps, I still have the issue. (I noticed earlier that if I don't close the preview window, it will continue to preview the re-created PDFs each time I knit, but that's never been my workflow. I don't like to keep that window hanging around, so I always close it when I go back to my Rmd to make more changes.)
For a reprex, I was going to use the Rmd that I'm left with after following your steps above, but I can't upload an Rmd file, and using that reprex library/command doesn't work on the content of an Rmd file, apparently, as it fails and says the first 3 lines aren't R code. Please let me know if I'm missing something. But essentially, it happens on all Rmds, including the sample Rmd you get when you start a new one.
I re-ran to confirm that I had closed the preview window, but now see that I'm running 1.2.1194, which was released a month ago. I haven't experienced any problems with it. Also, just for belts and suspenders, I'm on R 3.5.2 "Eggshell Igloo." Also, I update.packages() daily. I'd try all of those and if you still have the problem, I'll find out the information needed to open a support ticket.
It's fixed now, thank you! Upgrading to 1.2.1194 seemed to be at least part of the solution, as updating packages and upgrading R didn't fix it, but once I also upgraded R studio, the issue stopped. Thanks again!