Skip to content

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

Open
@mdehollander

Description

@mdehollander

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions