Skip to main content

resolve_app_root

Function resolve_app_root 

Source
pub fn resolve_app_root(compiled_in_default: &str) -> String
Expand description

Overrides the compile-time-baked app root a generated app’s own paths() function would otherwise always use unconditionally (env!("CARGO_MANIFEST_DIR"), fixed at cargo build time to wherever the build happened to run) - the identical xr upgrade/ LARUST_CHECKOUT_ROOT pattern (see that command’s own resolve_checkout_root), applied here for the same reason: “baked in” doesn’t survive every real scenario. Without this, a binary built on one machine (a CI runner, a dev box) and then copied to a different directory on whatever actually serves it - rather than built in place there, the way xr deploy does it today - would still look for .env/ storage//database/ at the build machine’s own path, not wherever it actually ended up. Set LARUST_APP_ROOT as a real process environment variable (e.g. a systemd unit’s own Environment=LARUST_APP_ROOT=... line) to unlock exactly that - a minimal deployment needing nothing but the compiled binary and an .env file sitting next to wherever it’s actually run from.

Reads the override from the real process environment only, never from .env: .env’s own location is exactly what this function decides, so sourcing the override from inside the file it’s used to find in the first place would be circular.