rmarkdown::render Error in eval(expr, envir, enclos) for 'params' objects when 'intermediates_dir' option set to anything except 'NULL'
<p>I am trying to parameterize the rendering of chunks of an rmarkdown document. </p>

<p>To do this, I set the knitr chunk option <code>eval</code> to a parameter defined in the yaml header and can be passed as an option via <code>rmarkdown::render</code>'s <code>params</code> option.</p>

<p>Let's say the following is my rmarkdown document called <code>mydocument.Rmd</code>:</p>

<pre><code>---
title: "mydocument"
params: 
  query: TRUE
---

```{r}
query &lt;- params$query
```

```{r eval=query}
cat('Hello world\n') 
```
</code></pre>

<p>The rendering of this document works fine when I use </p>

<pre><code>rmarkdown::render(input = 'mydocument.Rmd', 
                 params = list(query = TRUE))
</code></pre>

<p>but when I use</p>

<pre><code>rmarkdown::render(input = 'mydocument.Rmd', 
                 params = list(query = TRUE),
                 intermediates_dir = getwd())
</code></pre>

<p>The rendering still works, and I get the expected html output but I get the error message:  </p>

<p><code>Error in eval(expr, envir, enclos) : object 'query' not found</code></p>

<p>If <code>mydocument.Rmd</code> looked like this:</p>

<pre><code>---
title: "mydocument"
params: 
  query: TRUE
---

```{r eval=params$query}
cat('Hello world\n') 
```
</code></pre>

<p>I get the error:</p>

<pre><code>Error in eval(expr, envir, enclos) : object 'params' not found
</code></pre>

<p>Somehow changing the default value of intermediates_dir option causes this problem. I tried all other options of the <code>rmarkdown::render</code> function, but none of them show this behaviour. </p>

<p>I am not sure if this problem is a problem of rmarkdown, knitr, or pandoc. </p>

<h3>Session Information</h3>

<p>R version 3.3.1 (2016-06-21)</p>

<p>Platform: x86_64-apple-darwin13.4.0 (64-bit)</p>

<p>Running under: OS X 10.11.6 (El Capitan)</p>

<p>locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8</p>

<p>attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     </p>

<p>other attached packages:
[1] rmarkdown_1.0</p>

<p>loaded via a namespace (and not attached):
 [1] magrittr_1.5    formatR_1.4     htmltools_0.3.5 tools_3.3.1     yaml_2.1.13     Rcpp_0.12.7<br>
 [7] stringi_1.1.1   knitr_1.14      stringr_1.1.0   digest_0.6.10   evaluate_0.9   </p>