-
Notifications
You must be signed in to change notification settings - Fork 409
Description
I have:
- searched the issue tracker for similar issues
- installed the latest version of Quarto CLI
- formatted my issue following the Bug Reports guide
Bug description
Hi, I am looking for a way to conditionally execute a chunk of Python code, based on the output format of the rendered document. I would like to use the QUARTO_EXECUTE_INFO environmental variable for this. However, I run into the problem that the QUARTO_EXECUTE_INFO is only accessible upon the very first render of the qmd file. Upon every re-render of the same file (changed or unchanged), I am not able to read the json anymore. The only reproducible way I found to get it back to work is to change the python kernel used to render the qmd file (i.e. replace jupyter: python3 with jupyter: myenv for example). Even then, it only works upon the very first execution and upon each subsequent re-render the json file cannot be accessed.
Steps to reproduce
---
title: 'Test'
date: last-modified
published-title: Last updated on
execute:
freeze: true
echo: false
warning: false
jupyter: python3
---
```{python}
import os
import json
for i in ["QUARTO_DOCUMENT_PATH", "QUARTO_EXECUTE_INFO", "QUARTO_PROJECT_ROOT"]:
print(f"{i}: {os.environ[i]}")
print('try to read in the json')
try:
with open(os.environ["QUARTO_EXECUTE_INFO"]) as f:
info = json.load(f)
# Access format information
print(f'json read in, output format is {info["format"]["identifier"]["target-format"]}')
except:
print('json not accessible')
```
To reproduce: run quarto render env_test.qmd --to html a few times in a row and inspect the result file each time
Actual behavior
on the very first render in a given kernel, the json to which QUARTO_EXECUTE_INFO is pointing to can be accessed, and on every next re-render it is not accessible.
Expected behavior
QUARTO_EXECUTE_INFO json should be accessible upon every re-render
Your environment
IDE: Notepad++
Windows 11
Quarto check output
> quarto check
Quarto 1.8.25
[>] Checking environment information...
Quarto cache location: C:\Users\t\AppData\Local\quarto
[>] Checking versions of quarto binary dependencies...
Pandoc version 3.6.3: OK
Dart Sass version 1.87.0: OK
Deno version 2.3.1: OK
Typst version 0.13.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
Version: 1.8.25
Path: C:\Users\t\AppData\Local\Programs\Quarto\bin
CodePage: 1252
[>] Checking tools....................OK
TinyTeX: v2025.10
Chromium: (not installed)
[>] Checking LaTeX....................OK
Using: TinyTex
Path: C:\Users\t\AppData\Roaming\TinyTeX\bin\windows\
Version: 2025
[>] Checking Chrome Headless....................OK
Using: Chrome found on system
Path: C:\Program Files\Google\Chrome\Application\chrome.exe
Source: Windows Registry
[>] Checking basic markdown render....OK
[>] Checking Python 3 installation....OK
Version: 3.12.12 (Conda)
Path: C:/APPS/Anaconda3/envs/tobireports/python.exe
Jupyter: 5.9.1
Kernels: python3, duckdb_env, tobireports
[>] Checking Jupyter engine render....OK
[>] Checking R installation...........OK
Version: 4.1.2
Path: C:/Users/t/Documents/R/R-4.1.2
LibPaths:
- C:/Users/t/Documents/R/R-4.1.2/library
knitr: 1.37
rmarkdown: 2.11
[>] Checking Knitr engine render......OK
> jupyter --version
Selected Jupyter core packages...
IPython : 9.6.0
ipykernel : 7.0.1
ipywidgets : not installed
jupyter_client : 8.6.3
jupyter_core : 5.9.1
jupyter_server : not installed
jupyterlab : not installed
nbclient : 0.10.2
nbconvert : not installed
nbformat : 5.10.4
notebook : not installed
qtconsole : not installed
traitlets : 5.14.3