{"record":{"id":"62cf4347ca44188e","repo":"dagger/dagger","slug":"local-module-dep-source-path-q-is-absolute","errorCode":null,"errorMessage":"local module dep source path %q is absolute","messagePattern":"local module dep source path %q is absolute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/modulesource.go","lineNumber":2145,"sourceCode":"\t\tctx,\n\t\tNewModuleSourceFS(bk, parentSrc),\n\t\tdepSrcRef,\n\t\tdepPin,\n\t)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to parse dep ref string: %w\", err)\n\t}\n\n\tswitch parsedDepRef.Kind {\n\tcase ModuleSourceKindLocal:\n\t\tif parentSrc == nil {\n\t\t\t// it's okay if there's no parent when the dep is git, but we can't find a local dep relative to nothing\n\t\t\treturn inst, fmt.Errorf(\"local module dep source path %q must be relative to a parent module\", depSrcRef)\n\t\t}\n\n\t\tif filepath.IsAbs(depSrcRef) {\n\t\t\t// they need to be relative to the parent module's source root\n\t\t\treturn inst, fmt.Errorf(\"local module dep source path %q is absolute\", depSrcRef)\n\t\t}\n\t\tif parentSrc.Workspace.Self() != nil {\n\t\t\tdepPath := filepath.Join(parentSrc.SourceRootSubpath, depSrcRef)\n\t\t\tif !filepath.IsLocal(depPath) {\n\t\t\t\treturn inst, fmt.Errorf(\"local module dep source path %q escapes workspace\", depSrcRef)\n\t\t\t}\n\t\t\tselectors := []dagql.Selector{{\n\t\t\t\tField: \"moduleSource\",\n\t\t\t\tArgs: []dagql.NamedInput{\n\t\t\t\t\t{Name: \"path\", Value: dagql.String(filepath.ToSlash(depPath))},\n\t\t\t\t},\n\t\t\t}}\n\t\t\tif depName != \"\" {\n\t\t\t\tselectors = append(selectors, dagql.Selector{\n\t\t\t\t\tField: \"withName\",\n\t\t\t\t\tArgs: []dagql.NamedInput{\n\t\t\t\t\t\t{Name: \"name\", Value: dagql.String(depName)},\n\t\t\t\t\t},","sourceCodeStart":2127,"sourceCodeEnd":2163,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/modulesource.go#L2127-L2163","documentation":"The dependency ref was parsed as a local module source but the string is an absolute filesystem path. Dagger requires local module dependencies to be expressed as paths relative to the parent module's source root so they can be resolved portably across clients and contexts.","triggerScenarios":"Declaring a dependency whose source is an absolute path (e.g. \"/home/user/proj/lib\" or \"C:\\\\lib\") in dagger.json or passing one to ModuleSource/ResolveDepToSource, and ParseRefString classifies it as a local ref with filepath.IsAbs true.","commonSituations":"Copy-pasting an absolute path from the shell into dagger.json; code generators emitting os-specific absolute paths; IDE autocomplete inserting full paths when adding a dependency.","solutions":["Replace the absolute path with a path relative to the parent module's source root, e.g. \"../lib\" instead of \"/home/me/proj/lib\".","If the dep lives outside the repo, either move it into the workspace or publish it to git and reference it by git URL.","Verify dagger.json's dependency \"source\" fields contain only relative paths.","Commit and test on another machine/OS to catch accidental absolute paths."],"exampleFix":"// dagger.json before\n{\"dependencies\": [{\"source\": \"/home/alice/work/shared-utils\"}]}\n// after\n{\"dependencies\": [{\"source\": \"../shared-utils\"}]}","handlingStrategy":"validation","validationCode":"if filepath.IsAbs(depRef) {\n    return fmt.Errorf(\"dependency %q must be a relative path, not absolute\", depRef)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint dagger.json so dependency sources are relative paths.","Compute dep paths with filepath.Rel from the module root rather than hardcoding.","Test dagger.json on a second machine to catch machine-specific absolute paths.","Use git dependencies for anything outside the repo."],"tags":["dagger","modules","path"],"backgroundTag":"absolute-path-not-allowed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}