relic run, the CLI decrypts your secrets and passes them to the runner, which spawns your command in an isolated environment with those secrets as environment variables.
The runner is written in Rust (compiled as a C-compatible dynamic library) because secret injection requires low-level control over process environments, memory, and signals that JavaScript runtimes do not provide.
How It Works
1
CLI prepares the data
The CLI decrypts secrets and serializes them as JSON along with the command to run.
2
FFI call
The CLI calls the runner’s
run_with_secrets function via Bun’s dlopen FFI. Two
null-terminated C strings are passed: the command and the secrets.3
Environment setup
The runner clears the child process environment entirely, then re-adds only an allowlist of
system variables (see Environment allowlist). Secrets are injected on
top.
4
Process spawn
The child process is spawned with the clean environment. On Unix, the runner forwards SIGTERM
and SIGINT so your process can shut down gracefully. On Windows, the runner resolves the command
through
PATHEXT and waits through Ctrl+C so it can report your process’s exit code.5
Cleanup
After the child exits, secret values are zeroed in memory (via
Zeroizing). The TypeScript side
also zeroes its buffers.Security Measures
Environment Allowlist
Only these variables from your shell reach the child process. Anything else, such as tokens exported in your shell profile, is dropped unless it is also a Relic secret. Secrets with the same name override the inherited value.- macOS / Linux
- Windows
Platform Support
Windows behavior
- Command resolution:
relic run -- npm startfindsnpm.cmdthe same waycmd.exewould, searching eachPATHdirectory for the extensions inPATHEXT. The current directory is not searched, so use.\build.cmdfor local scripts. Only.com,.exe,.bat, and.cmdfiles can be launched directly. - Shell built-ins and scripts: Commands such as
echo,dir, andsetare part ofcmd.exe, not executables. Run them through a shell:relic run -e dev -- cmd /c echo %API_URL%orrelic run -e dev -- pwsh -File deploy.ps1. - Argument quoting: Arguments are passed to the child exactly as your shell parsed them.
.batand.cmdfiles are launched throughcmd.exewith escaping applied by the Rust standard library, which refuses arguments it cannot escape safely instead of running them. - Ctrl+C: Windows sends console interrupts to every process in the console, so your command receives Ctrl+C directly. The runner ignores the interrupt while your command runs and exits with your command’s exit code once it stops.
- Crash dumps: There is no per-process equivalent of
RLIMIT_CORE. Windows does not write local crash dumps unlessLocalDumpsis configured under Windows Error Reporting.
Prebuilt Binaries
The runner is compiled as a C-compatible dynamic library (cdylib):
Prebuilt binaries ship in
apps/cli/prebuilds/<platform>/. In development, the CLI loads from packages/runner/target/release/.
Building from Source
target/release/librelic_runner.dylib (macOS), target/release/librelic_runner.so (Linux), or target\release\relic_runner.dll (Windows).