{"record":{"id":"d2246d44d8d1fc9e","repo":"cypress-io/cypress","slug":"file-not-found","errorCode":null,"errorMessage":"File not found.","messagePattern":"File not found\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"npm/cypress-schematic/src/schematics/ng-generate/cypress-test/index.ts","lineNumber":17,"sourceCode":"import {\n  Rule, Tree, SchematicsException, chain, mergeWith,\n} from '@angular-devkit/schematics'\n\nimport { virtualFs, workspaces } from '@angular-devkit/core'\n\nimport { Schema } from './schema'\n\nimport { createTemplate } from '../../utils'\n\nfunction createSpec (tree: Tree): workspaces.WorkspaceHost {\n  return {\n    async readFile (path: string): Promise<string> {\n      const data = tree.read(path)\n\n      if (!data) {\n        throw new SchematicsException('File not found.')\n      }\n\n      return virtualFs.fileBufferToString(data)\n    },\n    async writeFile (path: string, data: string): Promise<void> {\n      return tree.overwrite(path, data)\n    },\n    async isDirectory (path: string): Promise<boolean> {\n      return !tree.exists(path) && tree.getDir(path).subfiles.length > 0\n    },\n    async isFile (path: string): Promise<boolean> {\n      return tree.exists(path)\n    },\n  }\n}\n\nexport default function (options: Schema): Rule {\n  return async (tree: Tree) => {","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/npm/cypress-schematic/src/schematics/ng-generate/cypress-test/index.ts#L1-L35","documentation":"Raised by the readFile() implementation inside createSpec() (cypress-test ng-generate schematic) when tree.read(path) returns a falsy value while the Angular workspaces.readWorkspace API tries to read a file from the virtual tree. readWorkspace walks the workspace and asks the host for files; if a referenced file is absent from the schematic tree, readFile throws this generic SchematicsException.","triggerScenarios":"Running `ng generate @cypress/schematic:cypress-test` when the workspace references a file (commonly angular.json itself or a referenced tsconfig/schematics file) that is not present in the tree — e.g. corrupted workspace, a file deleted between parsing and generation, or a non-standard workspace layout.","commonSituations":"A workspace with a manually edited angular.json pointing at missing files; running the schematic from the wrong directory so relative paths do not resolve; an Angular CLI version that reads additional config files the workspace does not have; partial git checkout missing workspace files.","solutions":["Ensure you run the schematic from the Angular workspace root and that angular.json plus all referenced files exist.","Run `ng config` or `ng generate component --dry-run` to confirm Angular itself can read the workspace.","Restore any missing workspace files from version control before re-running the schematic.","Validate that the tree actually contains the file path reported (enable schematic debug logging) and fix the workspace reference."],"exampleFix":"// before: angular.json references a deleted tsconfig, schematic throws 'File not found.'\n// after: restore the referenced tsconfig (or remove the dangling reference), then re-run the schematic","handlingStrategy":"validation","validationCode":"// Before triggering the schematic, ensure angular.json and referenced files exist:\nimport fs from 'fs'\n\nconst required = ['./angular.json']\nfor (const f of required) {\n  if (!fs.existsSync(f)) {\n    throw new Error(`Missing workspace file required by the schematic: ${f}`)\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runSchematic('cypress-test', opts)\n} catch (e) {\n  if (e instanceof SchematicsException && /File not found/.test(e.message)) {\n    // a workspace file referenced by angular.json is missing — restore it, then retry\n  }\n  throw e\n}","preventionTips":["Run the schematic from the Angular workspace root.","Ensure angular.json references only files that exist.","Validate the workspace with `ng config` before generating."],"tags":["angular","schematic","ng-generate","workspace"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}