Skip to content

Odd scope error rendering in Quarto but not for rmarkdown::render #130

@matthew-brett

Description

@matthew-brett

I have run into a strange error rendering in Quarto that appears to be a scope problem. I do not see the same error when rendering in rmarkdown::render.

Consider the following document (also at https://github.com/matthew-brett/quarto-test-book/blob/main/intro.Rmd):

```{r}
source('setup.R')
# Contains only the following function:
# get_var <- function(name) {
#   return (get(name))
# }
```

```{r}
# Redefining the exact same function here fixes error below.
# get_var <- function(name) {
#   return (get(name))
# }
```

```{r}
p <- 1
```

```{r}
# No error
get('p')
```

```{r}
# Error here:
# Error in get(name) : object 'p' not found
# Calls: .main ... withCallingHandlers -> withVisible -> eval -> eval -> get_var -> get
get_var('p')
```

See the noted error in the last chunk, generated by quarto render.

There is no error for Rscript -e "rmarkdown::render('intro.Rmd')", and I get the expected output ([1] 1).

Is there something different about the scope or environment when executing via Quarto?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions