quarto-dev / quarto-dev/quarto-cli

Bash code chunks with profile enabled don't work when cache enabled

Open
#9,852 19 comments 0 reactions 1 assignee View on GitHub

@cderv is already working on this.

Since Jun 3, 2024.

bug computations engines-knitr
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

I have a Quartro Notebook (knitr flavor) with bash code chunks. I run them with the profile option enabled in order to run specific commands like mamba. Some parts take long to execute so I enabled caching. With a global enabled engine.opts='-l' and caching enabled, rendering fails with:

==> quarto preview conda.qmd --to html --no-watch-inputs --no-browse

processing file: conda.qmd
  |..........................................          |  80% [unnamed-chunk-1]running: bash  -c 'mamba env list'
Error in `system2()`:
! error in running command
Backtrace:
  1. global .main()
  2. execute(...)
  3. rmarkdown::render(...)
  4. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  5. knitr:::process_file(text, output)
     ...
 13. knitr (local) engine(options)
 14. base::tryCatch(...)
 15. base (local) tryCatchList(expr, classes, parentenv, handlers)
 16. base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 17. value[[3L]](cond)

Quitting from lines 16-17 [unnamed-chunk-1] (conda.qmd)
                                                                                                            
Execution halted

This is the quatro document:

---
title: "Conda"
format: html
editor: visual
engine: knitr
execute: 
  cache: true
---

```
{r setup}
library(knitr)
opts_chunk$set(engine.opts='-l')
```

```
{bash}
mamba env list
```

Either setting cache: false or explicitly adding engine.opts = '-l' to the code chunk works ok:

```
{bash, engine.opts='-l'}
mamba env list
```

Ideally I would like to setup the bash profiling only once, and just use plain bash code blocks without specifying the engine.opts every time. I guess there is a bug here when caching is enabled.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.