Skip to content

direnv

Repo box/github.com/opencharly/layer-direnv:v2026.272.0057

direnv — automatic per-directory environment loading from .envrc files direnv installs the direnv binary (one package name across fedora/arch/debian) AND declaratively wires the per-shell hook that makes .envrc autoload work. At charly box build the shell: schema bakes the hook into /etc/profile.d/charly-direnv-.sh for bash/zsh (the generic body eval "$(direnv hook <shell>)" with ${SHELL_NAME} substituted) and the fish-specific hook into /etc/fish/conf.d/charly-direnv.fish (direnv hook fish | source). sh is intentionally opted OUT (sh: {}): upstream direnv hook supports bash/zsh/fish/tcsh but NOT sh, so direnv hook sh errors on every shell that sources it. The scenarios assert the installed/runnable binary AND the baked hook drop-ins, so they fail if either the package or the shell wiring is missing.

Installed on every distro:

  • direnv

This candy’s plan: — the runnable spec charly check executes against a live deployment. check: steps are idempotent probes; run: steps change state.

Intent Step
check the direnv binary is installed at /usr/bin/direnv for the .envrc/.secrets autoload workflow
check direnv reports its version without error
check the bash shell-init drop-in EVALs the direnv hook, guarded to bash only (the guard stops bash from running the zsh drop-in, which /etc/profile also sources)
check the zsh shell-init drop-in EVALs the direnv zsh hook, guarded to zsh only
check NO sh drop-in is baked — direnv hook sh is not a valid target, so the sh:{} opt-out must suppress /etc/profile.d/charly-direnv-sh.sh (a file here means the invalid hook ships and errors on every sh)
check the zsh drop-in is guarded to zsh — sourcing it under bash must produce zero errors (the zsh body uses zsh-only syntax, so an unguarded drop-in errors under bash; this is the observable cross-shell regression)
check the fish shell-init drop-in is baked into its conf.d and sources the direnv fish hook
check package=direnv
check command=/usr/bin/direnv version