{"record":{"id":"2719b6e1774dfa15","repo":"angular/angular-cli","slug":"path-path-does-not-exist-2719b6","errorCode":null,"errorMessage":"Path \"${path}\" does not exist.","messagePattern":"Path \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"FileDoesNotExistException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/src/tree/host-tree.ts","lineNumber":301,"sourceCode":"      }\n    });\n  }\n\n  get root(): DirEntry {\n    return this.getDir('/');\n  }\n\n  // Readonly.\n  read(path: string): Buffer | null {\n    const entry = this.get(path);\n\n    return entry ? entry.content : null;\n  }\n\n  readText(path: string): string {\n    const data = this.read(path);\n    if (data === null) {\n      throw new FileDoesNotExistException(path);\n    }\n\n    const decoder = new TextDecoder('utf-8', { fatal: true });\n\n    try {\n      // With the `fatal` option enabled, invalid data will throw a TypeError\n      return decoder.decode(data);\n    } catch (e) {\n      // The second part should not be needed. But Jest does not support instanceof correctly.\n      // See: https://github.com/jestjs/jest/issues/2549\n      if (\n        e instanceof TypeError ||\n        (e as NodeJS.ErrnoException).code === 'ERR_ENCODING_INVALID_ENCODED_DATA'\n      ) {\n        throw new Error(`Failed to decode \"${path}\" as UTF-8 text.`, { cause: e });\n      }\n      throw e;\n    }","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/src/tree/host-tree.ts#L283-L319","documentation":"FileDoesNotExistException from HostTree.readText: read(path) returned null, meaning the file does not exist in the tree, and readText (which must return a string, not null) throws instead. This is the strict, typed counterpart to read(), which tolerates missing files by returning null.","triggerScenarios":"Calling tree.readText(path) for a path never created or already deleted; also indirectly via content() and applyChanges() when operating on an absent path.","commonSituations":"A schematic reads a config/template file that the target project does not have (different Angular version, standalone vs module-based, customized workspace); a prior rule's conditional create didn't run; wrong leading-slash path (relative 'src/...' vs '/src/...').","solutions":["Guard with if (!tree.exists(path)) { tree.create(path, defaultContent); } before calling readText.","Use tree.read(path) which returns Buffer|null and handle null yourself.","Fix the path — ensure it is absolute (leading '/') and matches the actual project layout.","Ensure the rule that creates the file executes before the rule that reads it (rule ordering in chain())."],"exampleFix":"// before\nconst text = tree.readText('/angular.json');\n// after\nif (!tree.exists('/angular.json')) {\n  throw new SchematicsException('Not inside an Angular workspace.');\n}\nconst text = tree.readText('/angular.json');","handlingStrategy":"validation","validationCode":"if (!tree.exists('/angular.json')) {\n  throw new SchematicsException('Not inside an Angular workspace.');\n}","typeGuard":"function hasText(tree: Tree, path: string): boolean {\n  return tree.read(path) !== null;\n}","tryCatchPattern":"try { const text = tree.readText(path); } catch (e) { if (e instanceof FileDoesNotExistException) { /* create default or bail with SchematicsException */ } else { throw e; } }","preventionTips":["Use tree.exists() before readText","Prefer tree.read() (returns null) when absence is expected","Ensure path is absolute with a leading '/'","Order chain() rules so creators run before readers"],"tags":["schematics","file-not-found","readtext"],"backgroundTag":"file-does-not-exist","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}