Environment
The runtime sets a handful of environment variables before executing the entrypoint. Packaged apps can read these to discover their own context.
Set by the runtime
| Variable | Value | Example |
|---|---|---|
ONELF_DIR | Mount/extract root | /run/user/1000/onelf-myapp-ab12cd34 |
ONELF_ACTIVE_MODE | Active mode | fuse, tmpfs, memfd, cache, dev |
ONELF_ARGV0 | Original argv[0] | myapp |
ONELF_EXEC | Path to the packed binary | /home/alice/bin/myapp.onelf |
ONELF_ENTRYPOINT | Active entrypoint name | myapp-daemon |
ONELF_LAUNCH_DIR | Caller's original cwd | /home/alice/project |
Library paths
The runtime walks the AppDir's lib subdirectories and builds a search-path string of the form:
<resolver link farm>:<bundle lib dirs>:<previous LD_LIBRARY_PATH>That string is used two ways:
- Passed to the bundled dynamic linker via
--library-pathwhen the runtime invokes it explicitly. - Set as
LD_LIBRARY_PATHfor AT_EXECFN-bootstrapped binaries, which reach the bundled libraries through their own run path and only need the farm from the environment, so that nested execs the app does still resolve correctly.
The link farm holds the host libraries the runtime's resolver chose for this launch: the driver stack the bundle does not carry, and any library whose host copy is newer than the bundled one. See Bundling for how the choice is made. No host directory is ever placed on the path, so a library the bundle lacks and the resolver did not choose fails by name instead of being satisfied from the host.
If the AppDir has lib/dri/ or lib/gbm/ it also sets:
LIBGL_DRIVERS_PATHandLIBVA_DRIVERS_PATHtolib/dri/GBM_BACKENDS_PATHtolib/gbm/
If the AppDir has share/vulkan/icd.d/ it sets:
VK_DRIVER_FILESto the colon-joined list of ICD json files
The runtime also auto-sets a few more vars when the corresponding data directory exists:
__EGL_VENDOR_LIBRARY_DIRSforshare/glvnd/egl_vendor.d/LIBDRM_IDS_PATHforshare/libdrm/LIBDECOR_PLUGIN_DIRforshare/libdecor/plugins-1/DRIRC_CONFIGDIRforshare/drirc.d/XKB_CONFIG_ROOTforshare/X11/xkb/
Finally, the package's own share/ is prepended to XDG_DATA_DIRS, so GLib/GTK discover bundled GSettings schemas and icon themes.
Custom environment variables
The recipe's [env] section lets the package declare extra env vars the runtime should set. ${ONELF_DIR} in values expands to the package root at runtime, so paths follow the running app:
[env]
PYTHONHOME = "${ONELF_DIR}/python"
QT_PLUGIN_PATH = "${ONELF_DIR}/lib/qt6/plugins"${ONELF_DIR} and $${VAR} (escaped, expanded against the live environment at runtime, with POSIX ${VAR:-word} defaults) let values prepend instead of replace. PATH defaults to ${ONELF_DIR}/bin:$${PATH:-/usr/bin:/bin}, so the package's bin/ is always on PATH (re-exec-safe), falling back to /usr/bin:/bin when the inherited PATH is empty, unless [env] sets PATH itself.
See Recipe File for details.
Surviving a sandboxed re-exec
Some apps re-exec themselves with a wiped environment (Chromium and Electron zygotes, Steam, bwrap-based sandboxes). Anything the runtime exported via LD_LIBRARY_PATH or [env] is lost across that clearenv() + execve(), because the runtime is no longer in the loop on the re-exec.
onelf makes this survive by moving the guarantee into the ELF itself, not the environment:
- Libraries:
bundle-libsbakes an$ORIGIN/../libDT_RUNPATHinto binaries, so bundled libs resolve relative to the binary's own location on every exec. Executables that could not get one (no in-place slot and nopatchelf, or self-extract binaries) are reported at pack time. They fall back toLD_LIBRARY_PATHand are not re-exec-safe. [env]andpreload: a tiny freestandingonelf-envconstructor is bundled intolib/and injected as aDT_NEEDEDof the entrypoint. BecauseDT_NEEDEDlives in the ELF and is resolved via the$ORIGINRUNPATH above, it loads on every exec; its constructor re-applies.onelf/envand.onelf/preloadbeforemain(), no matter how the app cleared the environment.
The onelf-env injection requires patchelf at pack time (set ONELF_PATCHELF to override its location) and a prebuilt onelf-env blob for the target architecture. When either is missing, packing prints a warning and [env] is applied only on the first launch (the runtime layer), not after a re-exec.
Set by the user
| Variable | Effect |
|---|---|
ONELF_MODE | Force a specific execution mode |
ONELF_GC_MAX_AGE | Cache GC threshold in days (default 30, 0 disables) |
ONELF_FUSE_NO_NAMESPACE | Force the fusermount3 path even when user namespaces work |
Portable directory redirection
If files named <binary>.home, <binary>.config, <binary>.share, <binary>.cache, or <binary>.env exist next to the packed binary, the runtime redirects the corresponding XDG env vars at them. See Portable Directories for details.