angular/angular-cli · error · SchematicsException

The specified include path '${options.include}' does not exi

Error message

The specified include path '${options.include}' does not exist.

What it means

Thrown by the jasmine-vitest refactor when the user-supplied --include path is neither a directory nor an existing file in the schematic Tree, so no test target can be resolved from it.

Source

Thrown at packages/schematics/angular/refactor/jasmine-vitest/index.ts:104

      const includePath = normalize(join(projectRoot, normalizedInclude));
      searchScope = options.include;

      let dirEntry: DirEntry | null = null;
      try {
        dirEntry = tree.getDir(includePath);
      } catch {
        // Path is not a directory.
      }

      // Approximation of a directory exists check
      if (dirEntry && (dirEntry.subdirs.length > 0 || dirEntry.subfiles.length > 0)) {
        // It is a directory
        files = findTestFiles(dirEntry, fileSuffix);
      } else if (tree.exists(includePath)) {
        // It is a file
        files = [includePath];
      } else {
        throw new SchematicsException(
          `The specified include path '${options.include}' does not exist.`,
        );
      }
    } else {
      searchScope = `project '${projectName}'`;
      files = findTestFiles(tree.getDir(projectRoot), fileSuffix);
    }

    if (files.length === 0) {
      throw new SchematicsException(
        `No files ending with '${fileSuffix}' found in ${searchScope}.`,
      );
    }

    for (const file of files) {
      reporter.incrementScannedFiles();
      const content = tree.readText(file);
      const newContent = transformJasmineToVitest(file, content, reporter, {

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Correct the --include path to an existing file or directory relative to the workspace root.
  2. Run `ls` on the path (or check it in the repo) to confirm it exists before running the refactor.
  3. Omit --include to fall back to scanning the whole project for test files ending in the suffix.
  4. If targeting spec files generically, rely on the default search (project root + fileSuffix) instead of --include.

Example fix

// before
ng ref jasmine-vitest --include src/app/servcie/*.spec.ts
// after
ng ref jasmine-vitest --include src/app
Defensive patterns

Strategy: validation

Validate before calling

const p = path.resolve(options.include);
if (!fs.existsSync(p)) {
  throw new Error(`--include path does not exist: ${p}`);
}

Type guard

function isExistingPath(p: string): boolean {
  try { return fs.existsSync(p); } catch { return false; }
}

Try / catch

try {
  await runJasmineVitestRefactor({ include: options.include });
} catch (e) {
  if (String(e.message).includes('include path')) {
    console.error(`Check the --include path (relative to workspace root): ${options.include}`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the refactor with an --include value (options.include) where tree.exists(includePath) is false and it is not a directory — misspelled path, path outside the project root, glob-only path, or a file that is not materialized in the Tree.

Common situations: Typos in --include; passing a glob pattern where a concrete file/dir is expected; paths relative to the wrong directory (repo root vs project root); file generated at runtime but not present in the tree.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/c3219980b9799090. Report an issue: GitHub.