Deserialization of Turing model fails in Quarto document

I have several results from an optimization serialized to disk. They are all NamedTuples result = (mdl = A Turing Model, chn = A Chains object) Now I want to return predictions from a model in my test.qmd file:

---
title: "Turing Serialization Test"
format: pdf
engine: julia
julia:
  exeflags: ["--project=@."]
  env: ["JULIA_NUM_THREADS=5"]
---

```{julia}
#| label: packages-scripts
using CSV, DataFrames, Turing, StatsBase, Random, Plots, StatsPlots
using ApproxFun, CategoricalArrays, NamedArrays, LaTeXStrings, Loess
using ADTypes, KernelDensity, Serialization, DynamicPPL, LinearAlgebra
using BenchmarkTools, IterTools, StatProfilerHTML, ReverseDiff
using Suppressor, Distributions
## using Enzyme

include("../src/utils.jl")
include("../src/estimation.jl")
include("../src/loadgermdata.jl")
include("../src/diag.jl")
include("../src/diagplots.jl")
include("../src/diagchain.jl")
include("../src/diagrbf.jl")
include("../src/norm.jl")
include("../src/rbf.jl")
include("../src/analysis.jl")

r = deserialize("output/optim30-50")[1]
returned(r.mdl.mdl, r.chn)

However, when doing quarto render test.qmd I get following error

UndefVarError: `Normal` not defined in `Main` Suggestion: check for spelling errors or missing imports. ```

Now, when putting the exact same code from the chunk into test.jl, it works. It also works when executing the code in test.qmd interactively and just sending it to the REPL. There are some Normal priors in the model. Any suggestions? I have no idea where to look for the error. For a simple toy model returned works just fine after deserialize.

Because Quarto runs stuff in a Jupyter notebook, maybe try putting the code in a notebook and see if it runs.

Because the YAML headers set

engine: julia

this file will not be routed through Jupyter for evaluation of the code blocks.

This sounds like a cache error. Are you sure you have turned cache off? Because if you cache then the packages do not get loaded in the next cell and your reference to Normal for example will be unknown. Can you post a more minimal example without all these includes?