windmill-labs/windmill · error · Error

Directory not found: ${targetDirectory}

Error message

Directory not found: ${targetDirectory}

What it means

Thrown by `wmill lint` (runLint) when the target directory does not exist. The CLI resolves the target from the explicit positional argument (or process.cwd()) and calls `stat()` on it; when stat fails (the catch maps it to null) it reports the path as not found before any linting starts.

Source

Thrown at cli/src/commands/lint/lint.ts:661

  return issues;
}

export async function runLint(
  opts: LintOptions,
  directory?: string,
): Promise<LintReport> {
  const initialCwd = process.cwd();
  const explicitTargetDirectory = directory
    ? path.resolve(initialCwd, directory)
    : undefined;

  const { json: _json, ...syncOpts } = opts;
  const mergedOpts = await mergeConfigWithConfigFile(syncOpts);
  const targetDirectory = explicitTargetDirectory ?? process.cwd();

  const stats = await stat(targetDirectory).catch(() => null);
  if (!stats) {
    throw new Error(`Directory not found: ${targetDirectory}`);
  }
  if (!stats.isDirectory()) {
    throw new Error(`Path is not a directory: ${targetDirectory}`);
  }

  // When the user specifies a subdirectory (that doesn't contain wmill.yaml),
  // skip include/exclude filters since they're relative to the project root.
  const isSubdirectory = explicitTargetDirectory &&
    !(await stat(path.join(targetDirectory, "wmill.yaml")).catch(() => null));
  const ignore = isSubdirectory
    ? (_p: string, _isDir: boolean) => false
    : await ignoreF(mergedOpts);
  const root = await FSFSElement(targetDirectory, [], false);
  const validator = new WindmillYamlValidator();

  const warnings: LintWarning[] = [];
  const issues: FileIssue[] = [];
  let scannedFiles = 0;

View on GitHub (pinned to e474e8803c)

Solutions

  1. Verify the path exists with `ls <dir>` and correct any typo in the argument.
  2. Run `wmill lint` from the repository root so the default (process.cwd()) is the right directory.
  3. If using a relative path, check it is relative to your current working directory, not to wmill.yaml.
  4. In CI, confirm the checkout/config step created the directory before the lint step runs.

Example fix

// before
wmill lint ./src/sripts

// after (typo fixed)
wmill lint ./src/scripts
Defensive patterns

Strategy: validation

Validate before calling

const target = explicitTargetDirectory ?? process.cwd();
if (!fs.existsSync(target) || !fs.statSync(target).isDirectory()) {
  throw new Error(`lint target must be an existing directory: ${target}`);
}

Try / catch

try {
  await runLint(opts, dir);
} catch (e: any) {
  if (e.message.startsWith("Directory not found")) {
    console.error(`Check the path: ${e.message}. cwd=${process.cwd()}`);
  }
  process.exitCode = 2;
}

Prevention

When it happens

Trigger: Running `wmill lint <dir>` where <dir> is misspelled, was deleted, is a dangling symlink, or running lint from a cwd that has been removed by another process.

Common situations: Typo in the path or wrong relative path depth; running the command after a branch switch/build cleanup removed the directory; a CI checkout step placed the project at a different path; dead symlink to a moved folder.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/ad22e82d9d97417a. Report an issue: GitHub.