Installer writes .env to ~/.claude/ but PAI looks in ~/.config/pai/
Summary
The Kai bundle installer writes environment variables (API keys, voice config) to ~/.claude/.env, but PAI's voice server and other components look for them in ~/.config/pai/.env.
Steps to Reproduce
- Run the Kai bundle installer
- Provide ElevenLabs API key and voice ID when prompted
- Try to use voice features
Expected Behavior
Environment variables should be written to ~/.config/pai/.env (the canonical PAI location)
Actual Behavior
Variables are written to:
~/.claude/.env~/.claude/settings.json
But the voice server loads from:
// voice-server/server.ts:14-15
const paiDir = process.env.PAI_DIR || join(homedir(), '.config', 'pai');
const envPath = join(paiDir, '.env');
Workaround
Copy the .env file manually:
cp ~/.claude/.env ~/.config/pai/.env
Suggested Fix
Either:
- Update installer to write to
~/.config/pai/.envinstead of~/.claude/.env - Or symlink
~/.config/pai/.env→~/.claude/.env - Or have PAI components check both locations
🤖 Generated with Claude Code
Thank you @nmitch17 for this detailed report! 🙏
PAI v2.1 addresses configuration management with a new settings.json.template approach - the installer no longer overwrites your existing settings. Environment handling has been improved across the board.
See the release: https://github.com/danielmiessler/PAI/releases/tag/v2.1.0
PAI_DIR is still being overwritten on update
The fix in b6bd951 addressed reading PAI_DIR in readExistingConfig(), but the write logic still overwrites existing PAI_DIR values.
Background
The old setup.sh allowed users to choose a custom installation directory (option 4). Users who chose ~/.config/pai have:
export PAI_DIR="$HOME/.config/pai"in their shell profile- All hooks and skills installed in
~/.config/pai/
The problem
When running the new install.ts (even with --update), it overwrites their custom PAI_DIR in settings.json with the hardcoded default ~/.claude.
Since Claude Code uses settings.json env vars (which override shell exports), hooks then try to load from ~/.claude while the actual files remain in ~/.config/pai.
Root cause
In Bundles/Official/install.ts lines 646-652:
const mergedSettings = {
...existingSettings,
env: {
...(existingSettings.env as Record<string, string> || {}),
...(settingsJson.env as Record<string, string>), // <-- overwrites PAI_DIR
},
};
The merge order puts settingsJson.env (containing hardcoded PAI_DIR: claudeDir) after existing settings, so it always overwrites any custom PAI_DIR.
Suggested fix
Preserve existing PAI_DIR if present:
const existingPaiDir = (existingSettings.env as Record<string, string>)?.PAI_DIR;
const mergedSettings = {
...existingSettings,
env: {
...(existingSettings.env as Record<string, string> || {}),
...(settingsJson.env as Record<string, string>),
...(existingPaiDir ? { PAI_DIR: existingPaiDir } : {}),
},
};