Skip to content

Struggles with environment variables #331

@bbolker

Description

@bbolker

Following on from #217:

  • I can get one of the suggested solutions to work (specify env variables YAML frontmatter) but not the other (via _environment file); it would be nice to make _environment work, as the environment variables I need to define are specific to my environment and so shouldn't be used by others (another use case would be if they were API secrets ...)
  • I can't find the solution documented anywhere except in the (closed) issue, it would be nice if it were more visible.

A bit more detail:

  • I want to use RCall and my R installation is a non-standard place, so I need to set **LD_LIBRARY_PATH=/usr/local/lib/R/lib
  • if this env variable isn't set/seen from the running environment, RCall fails.

This works fine:

---
title: "Julia env test"
engine: julia
julia:
  env: [ "LD_LIBRARY_PATH=/usr/local/lib/R/lib" ]
---

```{julia}
ld_library_path = get(ENV, "LD_LIBRARY_PATH", "missing")
println("LD_LIBRARY_PATH = $ld_library_path")
```

if I remove the env: stuff in the YAML, then LD_LIBRARY_PATH is printed as "missing", even if I have an _environment file containing the line LD_LIBRARY_PATH=/usr/local/lib/R/lib (and even after issuing quarto call engine close env.qmd to make sure I was restarting the runner). As mentioned above, subsequent attempts to load/use RCall will fail (for me) if the env variable is not set.

I looked through

but couldn't find any relevant information (I may have missed it), either about the fact that QuartoNotebookRunner inherits environment variables differently, or describing the YAML solution that works.

Quarto version 1.7.32, Julia 1.11.6, Ubuntu 24.04.3 LTS, R (unstable) (2025-08-10 r88559). As far as I can tell I'm using version 0.17.3 of QuartoNotebookRunner (by digging down into my .julia/packages/QuartoNotebookRunner directory: I don't know a better way to figure this out ...

Results of quarto check:

Quarto 1.7.32
[✓] Checking environment information...
      Quarto cache location: /home/bolker/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.6.3: OK
      Dart Sass version 1.85.1: OK
      Deno version 1.46.3: OK
      Typst version 0.13.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.7.32
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/local/texlive/2024/bin/x86_64-linux
      Version: 2024

[✓] Checking Chrome Headless....................OK
      Using: Chrome found on system
      Path: /usr/bin/chromium-browser
      Source: PATH

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.3
      Path: /usr/bin/python3
      Jupyter: 5.3.2
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.6.0
      Path: /usr/local/lib/R
      LibPaths:
        - /usr/lib/R/site-library
        - /usr/local/lib/R/library
      knitr: 1.50
      rmarkdown: 2.29

[✓] Checking Knitr engine render......OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions