Skip to content

On Windows a SIMLOCK_HOME directly under a drive root fails every command with EPERM mkdir #1663

Closed

Description

@V3RON

On Windows, a SIMLOCK_HOME that sits directly under a drive root makes every command that starts the daemon fail:

> $env:SIMLOCK_HOME = 'D:\simlock-verify'
> simlock doctor
{"error":{"code":"INTERNAL","message":"EPERM: operation not permitted, mkdir 'D:\\'"}}

D:\sv\home (one level deeper) works. Seen on Windows 11 23H2, Node 22.23.5, main at c9d82e3.

Why

createDataDirectory (src/ports/daemon-launcher.ts:93) first runs mkdir(dirname(directory), { recursive: true }). For D:\simlock-verify that is mkdir('D:\\', { recursive: true }), and Node on Windows rejects a recursive mkdir of a drive root with EPERM even though it exists (node -e "require('fs').promises.mkdir('D:\\\\',{recursive:true})" → EPERM). The same call on POSIX for / succeeds.

A data folder on a second drive is a likely Windows setup: the device copies are several GB each.

Expected

A SIMLOCK_HOME such as D:\simlock works. Other mkdirp calls on a path whose parent is a drive root may have the same problem.

Part of #1068.

Written by an agent.

Activity

  1. added this to the Windows support milestone on Nov 17, 2026
  2. added
    bug:newReported. An agent may triage it (rule 8); the fast track may set it ready (rule 17).
    on Nov 17, 2026
  3. assigned and unassigned on Nov 17, 2026
  4. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Confirmed on Windows 11, Node 22.23.5, at cc22e32. Windows refuses mkdir of a drive root whether or not it is recursive; a folder under the root is fine:

    > node probe: mkdir('D:\\', {recursive}) / mkdir('D:\\simlock1663t-probe', {recursive}) / mkdir('D:\\')
    EPERM D:\          ok D:\simlock1663t-probe          nonrec EPERM
    > set SIMLOCK_HOME=D:\simlock1663t && node dist\cli\main.js doctor
    {"error":{"code":"INTERNAL","message":"EPERM: operation not permitted, mkdir 'D:\\'"}}
    

    The test on bug/1663-repro runs everywhere: a temporary folder stands in for the drive root, and a mocked mkdir refuses it with EPERM.

    src/ports/daemon-launcher.test.ts › "starts the daemon when the folder holding SIMLOCK_HOME exists but refuses mkdir"

    pnpm exec vitest run --project unit src/ports/daemon-launcher.test.ts
    AssertionError: promise rejected "Error: EPERM: operation not permitted, mk… { code: '…' }" instead of resolving
     ❯ createDataDirectory src/ports/daemon-launcher.ts:94:9
    

    Root cause

    Defect. createDataDirectory (src/ports/daemon-launcher.ts:94) always runs mkdir(dirname(directory), { recursive: true }), even when the parent already exists. When SIMLOCK_HOME sits directly under a drive root, that parent is the root, and Windows refuses it. The issue's diagnosis is right.

    Simplest fix

    Create the parent only when it is missing:

    const parent = dirname(directory);
    await stat(parent).catch(() => mkdir(parent, { recursive: true }));
    reproduction + updater/service launcher tests: 14 passed
    pnpm test:changed: 455 files, 7054 passed
    Windows, fix applied and rebuilt: doctor → {"findings":[],"sources":[]}; home populated; daemon stopped after
    

    Alternatives rejected

    • Skip the parent only when dirname(parent) === parent: special-cases roots; a stat covers every parent that exists.
    • Catch EPERM, then stat the parent: more code for the same result.

    Risk

    • If the parent is a file, the error is now mkdir(directory)'s ENOTDIR, where it used to be the recursive mkdir's EEXIST.
    • The doctor run on Windows hit no other mkdir of a drive root. The mode-less mkdirp fails only when asked for the root itself.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Written by an agent.

  5. removed their assignment
    on Nov 17, 2026
  6. added
    bug:readyAn agent may fix it.
    fast-trackBug set ready by the fast-track check, not the maintainer (rule 17).
    and removed
    bug:newReported. An agent may triage it (rule 8); the fast track may set it ready (rule 17).
    on Nov 17, 2026
  7. self-assigned this
    on Nov 17, 2026
  8. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1672 (#1663)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

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

Metadata

Metadata

Assignees

Labels

bug:readyAn agent may fix it.fast-trackBug set ready by the fast-track check, not the maintainer (rule 17).

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions