Skip to main content

Module child_env

Module child_env 

Source
Expand description

The host environment given to child processes: the minimal one for processes that do not inherit the whole environment (plugin processes, stdio MCP servers), and the computer’s own environment, without what an AppImage launcher added, for every process graphrt starts.

Lives in the core because both host crates that start such processes (graphrt-plugin, graphrt-mcp) already depend on it and on nothing else in common.

§AppImage

An application packaged as a Linux AppImage (e.g. the graphrt desktop app, which embeds these crates) runs with the bundle’s folders in front of LD_LIBRARY_PATH, PATH, PYTHONPATH, XDG_DATA_DIRS, … and with PYTHONHOME, GTK_PATH, GIO_MODULE_DIR, … pointing into the bundle (the AppImage’s AppRun and its GTK hook set them, without keeping the old values). The application needs them; a program of the computer started with them loads the bundle’s older libraries and fails, e.g. /usr/bin/env: …/libsystemd.so.0: version `LIBSYSTEMD_254' not found for a #!/usr/bin/env node launcher on Ubuntu 26.04. So when the running binary is inside $APPDIR, every entry inside $APPDIR is dropped for children: a list variable keeps its other entries, a variable with nothing left is removed, and the runtime’s APPIMAGE / ARGV0 / OWD are removed. Outside an AppImage (and on macOS / Windows) nothing changes.

Enums§

EnvFix
One change that gives a child the computer’s own environment back.

Constants§

DEFAULT_PASS_ENV
Host variables always passed to a child process that does not inherit the environment.

Functions§

appimage_env_fixes
The fixes for an environment vars of an application running from the AppImage mounted at appdir (see the module docs), sorted by name.
apply_env_fixes
apply_host_env with explicit fixes (tests, or an embedder that works them out itself).
apply_host_env
Gives a command that inherits the environment the computer’s own one: call it before the command’s own env calls. A Tokio command passes command.as_std_mut().
host_env_fixes
The fixes for this process, worked out once from the environment at the first call (empty outside a Linux AppImage).
host_var
name as a child gets it: the process value with host_env_fixes applied.
host_vars
The whole environment as a child gets it (for a command started after env_clear()).
minimal_env
The variables of DEFAULT_PASS_ENV plus extra that are set on the host, with their values, for a child started after env_clear().
set_child_env
Sets up the environment of a child process the way plugin processes and stdio MCP servers get it: the whole host environment when inherit, else only DEFAULT_PASS_ENV plus pass_env; either way as the computer has it, without an AppImage’s entries (host_env_fixes). Call it before the command’s own env calls. A Tokio command passes command.as_std_mut().
set_child_env_with
set_child_env with explicit fixes instead of this process’s ones (tests, or an embedder that works them out itself).