Skip to content

Prepend .kamal/bin to PATH during hook execution#1785

Open
jeremy wants to merge 2 commits intoextfrom
hook-bin-path
Open

Prepend .kamal/bin to PATH during hook execution#1785
jeremy wants to merge 2 commits intoextfrom
hook-bin-path

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Feb 20, 2026

Summary

  • Hooks can now call executables in .kamal/bin without qualification
  • .kamal/bin is prepended to $PATH inside with_env, which wraps every hook execution
  • PATH is restored after each hook via the existing ensure block
  • Same pattern as npm prepending node_modules/.bin for scripts

Stacked on #1784 (external commands).

Example

# .kamal/hooks/post-configure can now call:
claims release beta3

# instead of:
.kamal/bin/claims release beta3

Test plan

  • .kamal/bin is prepended to PATH when directory exists
  • PATH is unchanged when .kamal/bin is absent
  • PATH is restored after with_env returns

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.
Copilot AI review requested due to automatic review settings February 20, 2026 05:31
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_env method to automatically prepend .kamal/bin to PATH when the directory exists
  • Added prepend_kamal_bin_to_path helper 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.
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