### Bug description

TLDR: When using a custom Julia system image in a project, the first format renders fine, but subsequent try to use a different kernel w/o the system image. This works locally but not in CI. I *think* it may be due to daemon handling without TTY.

I have a project using Julia with a custom system image. I built an IJulia kernel called `julia-sysimage-1.8` that uses a system image located at `/precompiled.so`

My _quart.yml looks like
```yaml
project:
  title: "My Project"
jupyter: julia-sysimage-1.8

format:
  elsevier-pdf:
    latex-clean: false
    keep-tex: true
    
  elsevier-html:
    toc: true
    embed-resources: true
```

I write and render this project on my local machine inside a devcontainer specified as below. Where the image contains the system image, jupyter, ...

```json
{
	"name": "Quarto",
	"image": "MY_CUSTOM_IMAGE",

	"customizations": {
		"vscode": {
			"extensions": [
				"julialang.language-julia",
				"quarto.quarto"
			],
			"settings": {
				"julia.additionalArgs": ["--sysimage=/precompiled.so"],
				"quarto.render.renderOnSave": false
			}
		}
	},

	// due to https://github.com/quarto-dev/quarto-cli/issues/4122
	"postCreateCommand": "pip install --force-reinstall jupyter-client==7.4.9 && \
		julia --sysimage=/precompiled.so --project=@. -e \"using Pkg; Pkg.instantiate()\"",
		
	"features": {
		"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
			// "version": "prerelease",
			"version": "latest",
			"installTinyTex": true,
			"installChromium": false
		}
	}
}
```

Running `quarto render` from VSCode w/ the devcontainer works perfectly fine. HOWEVER, in CI I render using Docker-in-Docker via

```
- devcontainer up --workspace-folder .
- devcontainer exec --workspace-folder . quarto render papers/quarto --execute-daemon --output-dir ../../public
```

Building the container and rendering the pdf target takes about ~6min total both locally and in CI. However, the html target takes an additional 16 min in CI. Both renders show `Starting julia-sysimage-1.8 kernel...`.

Adding

````markdown
```{julia}
#| echo: true
versioninfo()
```

```{julia}
#| echo: false
println("Sysimage: $(unsafe_string(Base.JLOptions().image_file))")
```
````

shows that the first render target (pdf) uses the correct system image, while the second does not (wrong system image), despite printing `Starting julia-sysimage-1.8 kernel...` to stdout for both. Also using `--execute-daemon` when inside the devcontainer only starts a single kernel but two separate ones are started in the CI setup. The docs mention

> Accordingly, no daemon is created when documents are rendered without an active tty

which is what leads me to believe that tty handling may be the issue.

PDF:
<img width="737" alt="Screen Shot 2023-02-02 at 10 58 30 AM" src="https://user-images.githubusercontent.com/599421/216388613-6e377a89-d982-4e14-bc88-50a36cd344dc.png">

HTML:
<img width="823" alt="Screen Shot 2023-02-02 at 10 58 17 AM" src="https://user-images.githubusercontent.com/599421/216388710-278cf7ec-fde3-4762-96fa-bfdea444568e.png">

I realize that this a complex example. I could provide a minimal setup but that would still require somebody to compile a custom system image which is non-trivial. Thanks.

Local machine : OSX w/ Debian 11-based devcontainer
CI Runner: Debian 11 -> docker:latest -> same devcontainer as local machine.




### Checklist

- [ ] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [ ] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
2023-02-02T17:11:45Z
agerlach
bug needs-repro
closed
Projects w/ multiple output formats uses different kernels per render
https://github.com/quarto-dev/quarto-cli/issues/4192