Skip to content

DMG install: LOG_LEVEL change via Hub has no effect — .env not loaded on startup #1062

Description

@mindfn

Problem

DMG-installed users cannot change the log level. Two issues compound:

  1. Hub PATCH writes .env but DMG startup doesn't read it: PATCH /api/config/env writes LOG_LEVEL=debug to resolve(projectRoot, '.env') and updates process.env in memory (config.ts:352-356). But the DMG app startup doesn't source .env — there's no dotenv in the Node code, and the DMG launcher doesn't go through start-dev.sh (which does source .env). After restart, process.env.LOG_LEVEL is undefined → falls back to default 'info'.

  2. Runtime process.env update doesn't affect pino: Even during the current session, process.env.LOG_LEVEL = 'debug' has no effect because pino logger level is set at import time (logger.ts:22):

    const LOG_LEVEL = (isDebugMode ? 'debug' : (process.env.LOG_LEVEL ?? 'info')) as pino.Level;

    This is a module-level constant evaluated once at process start.

Result

LOG_LEVEL changes via Hub appear to save (UI shows "debug") but logs remain at level 30/40 (info/warn), never 20 (debug). Neither runtime change nor restart fixes it.

Fix

Option C (recommended): When PATCH /api/config/env changes LOG_LEVEL, also call logger.level = newValue to update the live pino instance. Pino supports runtime level changes natively. This gives instant effect without restart.

// In config.ts PATCH handler, after process.env update:
if (updates.has('LOG_LEVEL')) {
  const { logger } = await import('../infrastructure/logger.js');
  const newLevel = updates.get('LOG_LEVEL') || 'info';
  logger.level = newLevel;
}

Additionally, for DMG startup persistence:

  • Option B (complementary): Add dotenv loading at API entry point, or have the DMG launcher source .env if it exists.

Impact

All DMG-installed users. Debug logging is the primary diagnostic tool — without it, users can't troubleshoot MCP loading failures, auth issues, etc.

Files

  • packages/api/src/routes/config.ts:294-397 — PATCH /api/config/env handler
  • packages/api/src/infrastructure/logger.ts:22 — import-time LOG_LEVEL capture

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions