NBPR.Application (NBPR v0.2.1)

Copy Markdown View Source

Sets up PATH, LD_LIBRARY_PATH, and any package-declared runtime_env so external programs spawned by the BEAM can find every loaded nbpr package's binaries, shared libraries, and runtime resources.

Each nbpr package ships its target/ artefacts under its own priv/ (so Mix release semantics stay intact and packages can't stomp on each other in the rootfs). At runtime, :code.priv_dir/1 points at the right place, but child processes invoked via System.cmd/2, Port.open/2, or MuonTrap need PATH and LD_LIBRARY_PATH populated to find sibling-package binaries and inter-package shared libraries (e.g. nbpr_ffmpeg linking against libavcodec.so from nbpr_libav).

This Application sets both env vars once at boot, before any user code starts. :nbpr is a transitive dependency of every nbpr package, so OTP's application start order guarantees this runs first. By the time Application.loaded_applications/0 is queried, every nbpr_* .app file is loaded into the application controller (load is separate from start), so :code.priv_dir/1 resolves correctly for all of them.