{"record":{"id":"41e009c060272032","repo":"FuelLabs/fuels-ts","slug":"config-file-not-found","errorCode":"CONFIG_FILE_NOT_FOUND","errorMessage":"TOML file not found:\n  ${dir}","messagePattern":"TOML file not found:\n  (.+?)","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/fuels/src/cli/config/forcUtils.ts","lineNumber":50,"sourceCode":"  predicate = 'predicate',\n  library = 'library',\n}\n\nexport const swayFiles = new Map<string, SwayType>();\n\nexport const getClosestForcTomlDir = (dir: string): string => {\n  let forcPath = join(dir, 'Forc.toml');\n\n  if (existsSync(forcPath)) {\n    return forcPath;\n  }\n\n  const parent = join(dir, '..');\n  forcPath = getClosestForcTomlDir(parent);\n\n  if (parent === '/' && !existsSync(forcPath)) {\n    const msg = `TOML file not found:\\n  ${dir}`;\n    throw new FuelError(FuelError.CODES.CONFIG_FILE_NOT_FOUND, msg);\n  }\n\n  return forcPath;\n};\n\nexport function readForcToml(contractPath: string) {\n  if (!existsSync(contractPath)) {\n    throw new FuelError(\n      FuelError.CODES.CONFIG_FILE_NOT_FOUND,\n      `TOML file not found:\\n  ${contractPath}`\n    );\n  }\n\n  const forcPath = getClosestForcTomlDir(contractPath);\n\n  if (!existsSync(forcPath)) {\n    throw new FuelError(\n      FuelError.CODES.CONFIG_FILE_NOT_FOUND,","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/fuels/src/cli/config/forcUtils.ts#L32-L68","documentation":"Thrown by getClosestForcTomlDir when its recursive walk from `dir` up to the filesystem root never finds a Forc.toml. The function is used to locate the Forc workspace owning a Sway program; reaching '/' without a hit means no workspace is associated with the supplied path.","triggerScenarios":"Calling getClosestForcTomlDir (transitively, via config resolution) on a directory that is not inside any Forc workspace, or whose path is misconfigured in fuels.config.ts.","commonSituations":"A contract/predicate/script path in fuels.config.ts points outside the workspace, a typo in the path, a Sway project missing its Forc.toml, or running the CLI from the wrong working directory.","solutions":["Confirm a Forc.toml exists at the workspace root and that the configured path is inside it.","Fix the path in fuels.config.ts — it should be relative to the config file and within the workspace.","Create a Forc.toml at the program directory if the project genuinely lacks one.","Run fuels from the directory containing fuels.config.ts."],"exampleFix":"// before — config points outside workspace\ncontracts: ['../other-project/contract']\n// after\ncontracts: ['./contracts/my-contract']","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nimport { join } from 'path';\nfunction assertInsideWorkspace(dir: string): void {\n  let cur = dir;\n  while (true) {\n    if (existsSync(join(cur, 'Forc.toml'))) return;\n    const parent = join(cur, '..');\n    if (parent === cur) throw new Error(`no Forc.toml above ${dir}`);\n    cur = parent;\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep all Sway program paths inside the Forc workspace root.","Run fuels from the workspace root directory.","Add a lint step that verifies each config path resolves under the workspace."],"tags":["cli","config","forc","workspace","filesystem"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}