{"record":{"id":"72a68706d051958f","repo":"jdx/mise","slug":"go-workspace-module-is-missing-go-mod-72a687","errorCode":null,"errorMessage":"Go workspace module {} is missing go.mod","messagePattern":"Go workspace module (.+?) is missing go\\.mod","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/workspace/go.rs","lineNumber":63,"sourceCode":"\n        for directory in module_directories {\n            let candidate = if directory.is_absolute() {\n                directory\n            } else {\n                workspace_root.join(directory)\n            };\n            let lexical_candidate = lexical_absolute(&candidate)?;\n            if !lexical_candidate.starts_with(&lexical_root)\n                && !lexical_candidate.starts_with(&canonical_root)\n            {\n                continue;\n            }\n            let candidate = lexical_candidate;\n            if !context.exists(&candidate) {\n                if missing_path_resolves_outside(&candidate, &lexical_root, &canonical_root)? {\n                    continue;\n                }\n                bail!(\n                    \"Go workspace module {} is missing {GO_MOD}\",\n                    candidate.display()\n                );\n            }\n            let canonical_module = context.canonicalize(&candidate).wrap_err_with(|| {\n                format!(\n                    \"failed to resolve Go workspace module {}\",\n                    candidate.display()\n                )\n            })?;\n            let Ok(relative) = canonical_module.strip_prefix(&canonical_root) else {\n                continue;\n            };\n            if !context.is_file(&canonical_module.join(GO_MOD)) {\n                bail!(\n                    \"Go workspace module {} is missing {GO_MOD}\",\n                    candidate.display()\n                );","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/task/workspace/go.rs#L45-L81","documentation":"Go workspace (go.work) discovery resolves each module candidate listed by the Go workspace. If the candidate go.mod path does not exist, mise first checks whether it resolves outside the canonical workspace root (in which case it is silently skipped); if it still falls inside the root but is missing, discovery bails saying the module is missing its go.mod.","triggerScenarios":"A go.work `use` entry (or member directory found during discovery) points at a directory that exists in the workspace but has no go.mod file; discover_with_context, called from discover, hits context.exists(candidate) == false and missing_path_resolves_outside returns false.","commonSituations":"Deleting a module's go.mod while leaving its `use` line in go.work; adding a `use ./pkg` before running `go mod init`; switching branches where go.work references modules the branch doesn't contain; typos in the use path creating a nonexistent in-root directory.","solutions":["Run `go mod init <module-path>` in the referenced directory (or `go work use -r .`) so the go.mod exists.","Remove the stale `use` entry from go.work with `go work use` / `go work edit -dropuse ./path`.","Fix the path in go.work if it has a typo; ensure all listed modules are present at that branch/checkout."],"exampleFix":"// before (go.work)\ngo 1.22\nuse (\n\t./apps/api\n\t./apps/missing // directory has no go.mod\n)\n\n// after\ngo 1.22\nuse ./apps/api\n","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst work = fs.readFileSync('go.work', 'utf8');\nfor (const m of work.matchAll(/use\\s+(\\.\\/[^\\s)]+)/g)) {\n  if (!fs.existsSync(`${m[1]}/go.mod`)) {\n    throw new Error(`go.work uses ${m[1]} but go.mod is missing; run 'go mod init' or drop the use line`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await mise.run(['task', 'run', name]);\n} catch (e) {\n  if (/Go workspace module .* is missing go\\.mod/.test(e.message)) {\n    const dir = e.message.match(/module (\\S+) is missing/)?.[1];\n    require('child_process').execSync(`go mod init $(basename ${dir})`, { cwd: dir });\n  } else { throw e; }\n}","preventionTips":["Always run `go work use ./dir` (which validates go.mod) instead of hand-editing go.work.","After deleting a module, immediately update go.work (`go work edit -dropuse ./dir`).","Verify all `use` targets exist on every branch your team checks out; add a CI precheck."],"tags":["go","workspace","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}