decolua/9router · warning

[DATA_DIR] '${configured}' is a Unix path on Windows → fallb

Error message

[DATA_DIR] '${configured}' is a Unix path on Windows → fallback to default

What it means

Startup warning from getDataDir() in src/lib/dataDir.js. When DATA_DIR is set on a Windows host but the value is a Unix-style absolute path (starts with '/'), the directory cannot be a valid Windows location, so the function logs this warning and falls back to the default directory (~/.<APP_NAME>). This exists because Linux-targeted .env or Docker configs are commonly reused on Windows.

Source

Thrown at src/lib/dataDir.js:21

import os from "os";

const APP_NAME = "9router";

function defaultDir() {
  if (process.platform === "win32") {
    return path.join(process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"), APP_NAME);
  }
  return path.join(os.homedir(), `.${APP_NAME}`);
}

export function getDataDir() {
  const configured = process.env.DATA_DIR;
  if (!configured) return defaultDir();

  // On Windows, ignore Unix-style absolute paths (e.g. /var/lib/...) that come
  // from a Linux-targeted .env or Docker config — they are not valid here.
  if (process.platform === "win32" && /^\//.test(configured)) {
    console.warn(`[DATA_DIR] '${configured}' is a Unix path on Windows → fallback to default`);
    return defaultDir();
  }

  try {
    fs.mkdirSync(configured, { recursive: true });
    return configured;
  } catch (e) {
    if (e?.code === "EACCES" || e?.code === "EPERM") {
      console.warn(`[DATA_DIR] '${configured}' not writable → fallback ~/.${APP_NAME}`);
      return defaultDir();
    }
    throw e;
  }
}

export const DATA_DIR = getDataDir();

View on GitHub (pinned to 90b52e06ff)

Solutions

  1. Set DATA_DIR to a Windows-style path, e.g. DATA_DIR=C:\\9router-data or D:/data/9router.
  2. Remove DATA_DIR entirely to use the default ~/.<APP_NAME> location.
  3. Keep OS-specific .env files (.env.windows / .env.linux) or use forward-slash Windows paths (C:/...) which pass the check.

Example fix

// before (.env on Windows)
DATA_DIR=/var/lib/9router
// after
DATA_DIR=C:/9router-data
Defensive patterns

Strategy: validation

Validate before calling

const d = process.env.DATA_DIR;
if (process.platform === "win32" && d && /^\//.test(d)) {
  console.warn("DATA_DIR is a Unix path on Windows; set a Windows path like C:/9router-data");
}

Prevention

When it happens

Trigger: process.platform === 'win32' and process.env.DATA_DIR matches /^\// (e.g. DATA_DIR=/var/lib/9router in a .env copied from a Linux box or Docker Compose file).

Common situations: Copying a Linux .env to a Windows dev machine; Docker-style env files run natively on Windows; WSL paths used outside WSL; team-shared config with mixed OSes.

Related errors


AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30). Data as JSON: /api/errors/8be7f98b7b860d23. Report an issue: GitHub.