title: Shiny download report cannot run examples locally
body: <p>I want to create a shiny app that lets me download reports.  As such I have found two examples by Yihui.  <a href="https://gist.github.com/yihui/6091942" rel="nofollow">Example 1</a>, <a href="https://github.com/rstudio/shiny-examples/tree/master/016-knitr-pdf" rel="nofollow">Example 2</a>.</p>
  
  <p>I can run the gist (example 1) by <code>shiny::runGist()</code> and it works fine.  I am able to download the example document.  When I copy the code and run the app from R Studio I receive the following error when I try to download the document:</p>
  
  <pre><code> Running 'texi2dvi' on 'input.tex' failed.
      Messages:
      /usr/bin/texi2dvi: pdflatex exited with bad status, quitting.
      /usr/bin/texi2dvi: see input.log for errors.
  </code></pre>
  
  <p>I have researched this error and came upon <a href="https://support.rstudio.com/hc/communities/public/questions/200659606-pdflatex-problem" rel="nofollow">this</a> link and it seems to be the same problem, although it remains unresolved.    </p>
  
  <p>I have gone through the suggestions and I believe it has something to do with my PATH, although this is a subject I am unfamiliar with and trying to understand.  Typing the command <strong>$PATH</strong> into terminal I receive the following:</p>
  
  <p>-bash: <strong>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/texbin</strong>: No such file or directory</p>
  
  <p>I also opened the app in my browser.  I received the following different error when trying to download the document from the browser:</p>
  
  <pre><code>.onLoad failed in loadNamespace() for 'tcltk', details:
  call: system2("otool", c("-L", shQuote(DLL)), stdout = TRUE)
  error: error in running command
  </code></pre>
  
  <p>I continue to receive this error when I try to run the app in R Studio and X11 now opens.  </p>
  
  <p>I receive the same error when I try to load the package tcltk package.</p>
  
  <p>The example 2 I am able to run and download a document on my machine, but it is only partially compiled, and does not look like the document I download from the same app running on the shiny gallery <a href="http://shiny.rstudio.com/gallery/download-knitr-reports.html" rel="nofollow">here</a>.</p>
  
  <p>My document looks like </p>
  
  <blockquote>
    <p>Here is my regression model:</p>
    
    <p>options(digits = 4)  fit &lt;- lm(regFormula(), data = mtcars)b &lt;-
    coef(fit)summary(fit)The fitting result is          <em>mpg = r b[1] + r
    b[2]r input</em>x $. Below is a scatter plot with the regression line.</p>
    
    <p>par(mar = c(4, 4, 1, 1)) plot(regFormula(), data = mtcars, pch = 19,
    col = 'gray')abline(fit, col = 'red', lwd = 2)</p>
  </blockquote>
  
  <p>I am not sure if these problems are linked or separate. </p>
  
  <p>I am hesitant to make changes to my PATH because it is unfamiliar to me, but if this is what I need to focus on please let me know. I appreciate any help and direction offered.</p>
  
  <p>This is on mac OS X Lion version 10.7.5</p>