{"record":{"id":"5116ce5180488edc","repo":"jdx/mise","slug":"go-workspace-module-is-missing-go-mod","errorCode":null,"errorMessage":"Go workspace module {} is missing {GO_MOD}","messagePattern":"Go workspace module (.+?) is missing (.+?)","errorType":"validation","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/533346cc374382b41ec5ff70536252b2e96e725c/src/task/workspace/go.rs#L45-L81","documentation":"During Go workspace discovery, mise resolves each `use` directory from go.work and requires it to exist. If the candidate directory does not exist and the miss is not attributable to lexical-vs-canonical path divergence (i.e. it does not resolve outside the workspace), discovery fails with 'module ... is missing go.mod'. The message is slightly misleading: the immediate trigger is that the directory itself is absent.","triggerScenarios":"A `go.work` file contains `use ./somedir` (or an absolute use path inside the workspace root) but `somedir/` does not exist on disk when mise runs workspace discovery.","commonSituations":"Deleted or renamed module directory without updating go.work; checkout that skips empty dirs; uncommitted new module referenced by go.work; typo in the use path.","solutions":["Create the missing directory with a valid go.mod (`go mod init <module>`), or","Remove/fix the stale `use` entry in go.work (`go work use -r .` or edit it manually), or","Run `go work sync` / `go work use` to let Go regenerate a consistent go.work.","If the directory exists, check for symlinks or case-sensitivity mismatches that make the path resolve differently."],"exampleFix":"// before (go.work)\ngo 1.22\nuse ./services/old-api\n\n// after (directory was renamed)\ngo 1.22\nuse ./services/api","handlingStrategy":"validation","validationCode":"// shell, before relying on discovery\nwhile read -r dir; do\n  [ -d \"$dir\" ] || echo \"go.work references missing dir: $dir\"\ndone < <(go list -m -f '{{.Dir}}' all 2>/dev/null || awk '/^use/{print $2}' go.work)","typeGuard":null,"tryCatchPattern":"match discovery_result {\n    Err(e) if e.to_string().contains(\"is missing go.mod\") => {\n        eprintln!(\"stale go.work entry; regenerating\");\n        // run `go work use -r .` and retry\n    }\n    r => r?,\n}","preventionTips":["Regenerate go.work with `go work use -r .` after adding/removing/renaming modules","Never hand-delete a module directory without updating go.work","Commit go.work together with the directory changes it references"],"tags":["go","workspace","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}