Skip to content

fix(windows): use os.homedir() fallback so dmux starts on Windows#86

Open
pushp1997 wants to merge 1 commit intostandardagents:mainfrom
pushp1997:fix/windows-home-undefined
Open

fix(windows): use os.homedir() fallback so dmux starts on Windows#86
pushp1997 wants to merge 1 commit intostandardagents:mainfrom
pushp1997:fix/windows-home-undefined

Conversation

@pushp1997
Copy link
Copy Markdown

Summary

Fixes #85.

On Windows, process.env.HOME is undefined (Windows uses USERPROFILE). At src/index.ts:1148:

const homeDmuxDir = path.join(process.env.HOME!, '.dmux');

The ! non-null assertion lies to the type checker. At runtime, path.join(undefined, ...) throws TypeError: The "path" argument must be of type string. Received undefined. The exception is swallowed by .catch(() => process.exit(1)) at the bottom of init(), so Windows users see dmux silently exit with code 1 and never get past migrateOldConfig().

This PR replaces process.env.HOME! with process.env.HOME || os.homedir(), matching the safe pattern already used elsewhere in the codebase (src/utils/onboarding.ts, src/utils/openRouterApiKeySetup.ts, src/utils/tmuxConfigOnboarding.ts).

Changes

  • src/index.ts:
    • Add import os from 'os';
    • Replace process.env.HOME! with process.env.HOME || os.homedir() in migrateOldConfig()

Note on src/server/embedded-assets.ts

The same buggy line exists at src/server/embedded-assets.ts:1374 inside a template literal. That file has a DO NOT EDIT MANUALLY - Generated by scripts/embed-assets.js header, so I left it alone in this PR. Whatever generator produces it should pick up this change on the next regeneration. Happy to include a follow-up if you'd like it patched manually in the meantime.

Test plan

  • On Windows 11 / PowerShell 7, with the same patch applied locally to the installed dmux, dmux now successfully writes dmux.config.json and proceeds past migrateOldConfig() (exit 0 in non-TTY harness, ink UI launches in real terminals).
  • On macOS/Linux: behavior unchanged because process.env.HOME is set, so the || short-circuits before os.homedir() is even called. (No CI run yet from my fork.)

On Windows, process.env.HOME is undefined (Windows uses USERPROFILE).
path.join(undefined, ...) throws TypeError, which is silently swallowed
by the .catch(() => process.exit(1)) wrapping init(), causing dmux to
bounce back to the prompt with no diagnostic output.

Matches the existing process.env.HOME || os.homedir() pattern used
elsewhere in the codebase (utils/onboarding.ts, etc.).

Fixes standardagents#85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On Windows, dmux silently exits 1 because process.env.HOME is undefined

1 participant