Expand description
ONNX Runtime global environment: single init per process, runtime dylib loading.
With the load-dynamic Cargo feature (always enabled in lean-ctx’s ort
dependency), libonnxruntime is loaded at runtime via ort::init_from.
This module resolves the library path across platforms, including NixOS.
§Search order
ORT_DYLIB_PATHenv var (resolved relative to the executable directory)- The lean-ctx managed runtime (
lean-ctx embeddings provision, GH #732) — version-matched to this build’sortAPI level by construction - Nix profile paths (Linux):
/run/current-system/sw/lib/(system profile)/etc/profiles/per-user/$USER/lib/(NixOS Home Manager per-user)~/.nix-profile/lib/(legacy user profile symlink)
- Well-known system directories per platform, including the active
HOMEBREW_PREFIXand the standard Homebrew/Linuxbrew lib dirs LD_LIBRARY_PATH/DYLD_LIBRARY_PATH
If no copy is found, ensure_ort_env returns an eager error — session
creation hangs rather than failing, so we fail fast.
Functions§
- ensure_
ort_ env - Ensure the global ONNX Runtime environment is initialized.