Prepend .kamal/bin to PATH during hook execution#1785
Conversation
Hooks can now call executables in .kamal/bin without qualification, similar to how npm prepends node_modules/.bin for scripts. PATH is restored after each hook via the existing with_env ensure block.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b56711087
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR enables hooks to call executables in .kamal/bin without needing to qualify the path, by prepending .kamal/bin to the PATH environment variable during hook execution. This builds on PR #1784 which added support for git-style external commands.
Changes:
- Modified
with_envmethod to automatically prepend.kamal/binto PATH when the directory exists - Added
prepend_kamal_bin_to_pathhelper method to handle the PATH modification - Added comprehensive test coverage for PATH manipulation during hook execution
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/kamal/cli/base.rb | Added prepend_kamal_bin_to_path method and integrated it into with_env to prepend .kamal/bin to PATH during hook execution |
| test/cli/main_test.rb | Added tests verifying PATH is correctly prepended when .kamal/bin exists and unchanged when absent, plus PATH restoration after hook execution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Move prepend_kamal_bin_to_path from with_env (shared) into run_hook, since with_env is also used by build flows where .kamal/bin should not be on PATH.
Summary
.kamal/binwithout qualification.kamal/binis prepended to$PATHinsidewith_env, which wraps every hook executionensureblocknode_modules/.binfor scriptsStacked on #1784 (external commands).
Example
Test plan
.kamal/binis prepended to PATH when directory exists.kamal/binis absentwith_envreturns