Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

Installer writes .env to ~/.claude/ but PAI looks in ~/.config/pai/

Open nmitch17 opened this issue 10 months ago • 2 comments

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

  1. Run the Kai bundle installer
  2. Provide ElevenLabs API key and voice ID when prompted
  3. 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:

  1. Update installer to write to ~/.config/pai/.env instead of ~/.claude/.env
  2. Or symlink ~/.config/pai/.env → ~/.claude/.env
  3. Or have PAI components check both locations

🤖 Generated with Claude Code

nmitch17 avatar Jan 07 '26 19:01 nmitch17

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

danielmiessler avatar Jan 08 '26 12:01 danielmiessler

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 } : {}),
  },
};

MarkoSteenbergen avatar Jan 11 '26 15:01 MarkoSteenbergen