CLAUDE_ENV_FILE not supported on Windows - not documented
description
sessionstart hooks receive CLAUDE_ENV_FILE and can write export KEY=value lines to it, but on windows the env file is never sourced back. found the check in the cc source:
if(y$()==="windows")return N("Session environment not yet supported on Windows"),null;
cc creates the file path, passes it to hooks, hooks write to it successfully - but the sourcing function bails out on windows. the env vars never appear in bash tool calls or user ! commands.
expected behavior
CLAUDE_ENV_FILE works on windows the same as mac/linux, or the docs clearly state it's not supported on windows so plugin authors don't build on it.
actual behavior
- hook receives
CLAUDE_ENV_FILE(path is valid) - hook writes valid
export KEY=valuelines to the file - file exists on disk with correct content
- cc never sources it on windows
- env vars are empty in all bash contexts
- no error, no warning to the user or hook author
reproduction
- create a sessionstart hook that writes to
CLAUDE_ENV_FILE - start a session on windows
- run
echo $MY_VAR- empty
environment
- windows 11, claude code v2.1.97 and v2.1.98 (tested both)
- hooks fire correctly (confirmed via debug trace)
- hook stdout injection works fine - only env file sourcing is broken
impact
plugin authors building on CLAUDE_ENV_FILE (as documented in the hooks reference) will silently fail on windows with no indication of why. the feature appears to work (file path is provided, file is writable) but the sourcing never happens.
workaround
use pid file resolution or write to a known file on disk instead of relying on env vars.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗