Skip to main content

Module shell_sidecar

Module shell_sidecar 

Source
Expand description

Sidecar file that pins the --shell logic dylib path at install time.

cargo truce install --shell writes one of these per plugin; the shell binary loaded by the DAW reads it at first hot-reload to find the matching logic dylib.

§Path layout

~/.truce/shell/<crate_name>.path

<crate_name> matches the consuming crate’s CARGO_PKG_NAME. The file content is one line: the absolute path to the logic dylib (e.g. /Users/me/projects/my-plugin/target/shell/libmy_plugin.dylib). No TOML / no JSON — a single path keeps both writer and reader trivial and parser-free.

§Why ~/.truce/ and not the bundle

Per-bundle sidecars (e.g. MyPlugin.clap/Contents/.truce-shell) were considered, but the runtime read would need dladdr / GetModuleFileName to locate the shell binary’s own path on disk. Putting the sidecar at a crate_name-keyed home-relative path sidesteps that: the shell binary already has env!("CARGO_PKG_NAME") baked at compile time, so the read site needs only $HOME plus the crate name. Trade-off: only one shell install per crate at a time, which is fine — the only reason to install the same plugin twice is beta/release coexistence, and shell-mode is a dev-loop feature.

Functions§

sidecar_path
Resolve $HOME/.truce/shell/<crate_name>.path for a given crate. crate_name is the consuming crate’s CARGO_PKG_NAME — the reader passes env!("CARGO_PKG_NAME") and the writer passes the resolved plugin’s crate_name from truce.toml. Returns None when neither HOME (Unix) nor USERPROFILE (Windows) is set — the caller should fail loud rather than guess a path.