Fix hookify plugin imports missing CLAUDE_PLUGIN_ROOT fallback#31721
Open
RyanAlberts wants to merge 1 commit intoanthropics:mainfrom
Open
Fix hookify plugin imports missing CLAUDE_PLUGIN_ROOT fallback#31721RyanAlberts wants to merge 1 commit intoanthropics:mainfrom
RyanAlberts wants to merge 1 commit intoanthropics:mainfrom
Conversation
Made-with: Cursor
This was referenced Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #29842
When executing python hooks for the hookify plugin (
pretooluse.py,posttooluse.py,stop.py,userpromptsubmit.py), the environment variableCLAUDE_PLUGIN_ROOTmight not be present because it is only interpolated in the command string but not necessarily exported to the Python environment. This leads toHookify import error: No module named 'core'becausesys.pathdoes not get updated correctly.Changes Made
__file__-based fallback:PLUGIN_ROOT = os.environ.get('CLAUDE_PLUGIN_ROOT') or os.path.dirname(os.path.dirname(os.path.abspath(__file__))).CLAUDE_PLUGIN_ROOTenvironment variable is null, the script dynamically resolves the correct directory and updatessys.path, fixing the import crashes.Made with Cursor