# pdflatex problem with Rstudio

I'm trying to compile a simple Rnw file in Rstudio using knitr "compile pdf" functionality. But it gives me an error.

This is what I have in hello.Rnw:

\documentclass{article}

\begin{document}

Hello World

\end{document}


Error:

Running pdflatex.exe on hello.tex...failed

Error running C:/PROGRA~1/MIKTEX~1.9/miktex/bin/x64/pdflatex.exe (exit code 1)


However if I typeset hello.tex using TeXworks, it generates a pdf file without any error. I checked my Sys.getenv("PATH") variable, and it shows the correct MiKTeX location. So I'm not sure why RStudio pdflatex is not working.

"C:\\Users\\zk0q8r5\\Documents\\R\\R-3.5.0\\bin\\x64;
C:\\ProgramData\\Oracle\\Java\\javapath;
C:\\WINDOWS\\system32;
C:\\WINDOWS;
C:\\WINDOWS\\System32\\Wbem;
C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;
C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;
C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;
C:\\Program Files (x86)\\Microsoft Application Virtualization Client;
C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;
C:\\Program Files (x86)\\WebEx\\Productivity Tools;
C:\\Program Files\\TortoiseSVN\\bin;
C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64;
C:\\MiKTeX\\miktex\\bin\\x64\\"

• do you have a pdflatex.exe in C:\Program Files\MiKTeX 2.9\miktex\bin\x64 ? – David Carlisle May 2 '18 at 21:21
• @David, Yes, I've verified that there is a pdflatex.exe file at this location. – Sunny Kanugo May 2 '18 at 22:07
• @Fran, I'm not sure how it is going to MIKTEX~1.9 while there is no such version. I don't see any such version. I also tried rebooting the system but it didn't help. – Sunny Kanugo May 2 '18 at 22:09
• @Fran That is an 8.3 filename: en.wikipedia.org/wiki/8.3_filename You should not interpret ~1 as literally ~1. – Yihui Xie May 3 '18 at 2:26
• @YihuiXie Hahaha ...you are right. How I did not realize! The mistake is doubly silly because for a long time I was a DOS user before and after the onset of long names in Windows. Even today I hate names not limited to 8.3 characters in any OS, in part due to the problems that I had with the ~1 truncations. – Fran May 3 '18 at 9:39