Skip to content

Inject commands: PATH shims in anvil shell#5

Merged
voidreamer merged 1 commit into
mainfrom
claude/review-github-issues-7xL3x
Apr 21, 2026
Merged

Inject commands: PATH shims in anvil shell#5
voidreamer merged 1 commit into
mainfrom
claude/review-github-issues-7xL3x

Conversation

@voidreamer
Copy link
Copy Markdown
Owner

anvil shell <pkg> now materialises the package's commands: aliases as
PATH shims inside a fresh tempdir, prepends it to $PATH, and exports
$ANVIL_COMMAND_DIR. Closes the asymmetry where anvil run <pkg> -- foo
knew the alias map but a shell opened via anvil shell <pkg> did not.

  • POSIX (Linux/macOS): #!/usr/bin/env bash + exec <cmd> "$@", chmod 755.
    Works for bash/zsh/sh/fish and any shell that resolves external commands
    through the kernel (including pwsh on Unix).
  • Windows: .cmd wrapper resolvable through PATHEXT from cmd.exe,
    PowerShell, and pwsh.

Opt-outs: --env-only, ANVIL_DISABLE_COMMAND_SHIMS=1,
shell.inject_commands: false in config. --no-sweep skips the orphan
cleanup for debugging.

Orphaned shim tempdirs are swept on entry via a configurable
shell.orphan_ttl (default 1h) so SIGKILL'd shells never leak more than
one tempdir.

Ref #4

https://claude.ai/code/session_01V6KvHd4mVcM4XRwy4sNVSq

`anvil shell <pkg>` now materialises the package's `commands:` aliases as
PATH shims inside a fresh tempdir, prepends it to $PATH, and exports
`$ANVIL_COMMAND_DIR`. Closes the asymmetry where `anvil run <pkg> -- foo`
knew the alias map but a shell opened via `anvil shell <pkg>` did not.

- POSIX (Linux/macOS): `#!/usr/bin/env bash` + `exec <cmd> "$@"`, chmod 755.
  Works for bash/zsh/sh/fish and any shell that resolves external commands
  through the kernel (including pwsh on Unix).
- Windows: `.cmd` wrapper resolvable through PATHEXT from cmd.exe,
  PowerShell, and pwsh.

Opt-outs: `--env-only`, `ANVIL_DISABLE_COMMAND_SHIMS=1`,
`shell.inject_commands: false` in config. `--no-sweep` skips the orphan
cleanup for debugging.

Orphaned shim tempdirs are swept on entry via a configurable
`shell.orphan_ttl` (default 1h) so SIGKILL'd shells never leak more than
one tempdir.

Ref #4

https://claude.ai/code/session_01V6KvHd4mVcM4XRwy4sNVSq
@voidreamer voidreamer merged commit 6e9eec7 into main Apr 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants