{"record":{"id":"1e3f21538a845005","repo":"dagger/dagger","slug":"absolute-module-ref-q-requires-a-local-workspace","errorCode":null,"errorMessage":"absolute module ref %q requires a local workspace source","messagePattern":"absolute module ref %q requires a local workspace source","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/schema/workspace_client.go","lineNumber":225,"sourceCode":"\treturn resolved, nil\n}\n\n// resolveWorkspaceClientModuleRef normalizes a client's module ref into the two\n// forms it is needed in: loadRef, workspace-root-relative, is what module\n// loading reads from, while configRef is how the entry is spelled in the\n// dagger.toml at configDir. A canonical ref has no anchor, so it is both.\nfunc resolveWorkspaceClientModuleRef(ws *core.Workspace, ref, configDir string) (loadRef string, configRef string, _ error) {\n\tif !workspace.IsLocalRef(ref, \"\") {\n\t\treturn ref, ref, nil\n\t}\n\t// A local ref may be spelled with Windows separators; every path below this\n\t// point is addressed on the engine, where filepath treats a backslash as an\n\t// ordinary character.\n\tcleaned := filepath.Clean(strings.ReplaceAll(ref, `\\`, \"/\"))\n\tif filepath.IsAbs(cleaned) {\n\t\thostRoot, ok := ws.LocalSourceHostPath()\n\t\tif !ok {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"absolute module ref %q requires a local workspace source\", ref)\n\t\t}\n\t\trel, err := filepath.Rel(hostRoot, cleaned)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"compute workspace-relative module path: %w\", err)\n\t\t}\n\t\tcleaned = rel\n\t}\n\tif cleaned == \".\" || cleaned == \"\" {\n\t\tcleaned = \".\"\n\t}\n\tif cleaned == \"..\" || strings.HasPrefix(cleaned, \"..\"+string(filepath.Separator)) {\n\t\treturn \"\", \"\", fmt.Errorf(\"module ref %q must not escape the workspace root\", ref)\n\t}\n\tloadRef = filepath.ToSlash(cleaned)\n\tconfigRef, err := workspace.SDKManagedPathFor(configDir, loadRef)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/schema/workspace_client.go#L207-L243","documentation":"Thrown by resolveWorkspaceClientModuleRef in core/schema/workspace_client.go:225 when a client's module ref is an absolute filesystem path but the workspace has no local host source (LocalSourceHostPath fails). Absolute module refs can only be rewritten relative to the workspace root when the workspace is backed by a real local directory on the host.","triggerScenarios":"Passing an absolute module ref (e.g. /home/me/proj/shared, or a Windows path with backslashes) to dagger workspace client init / currentModuleAsSDKClientModuleSource while the workspace source is remote (e.g. a git-sourced or in-container workspace without a local host path).","commonSituations":"Running against a workspace whose source lives in a container/remote context while passing a host-absolute path; using an absolute path out of habit in CI where the workspace is not host-mounted.","solutions":["Use a module ref relative to the workspace root or your cwd instead of an absolute host path","Run the command from a workspace with a local host source directory (a checked-out workspace on the host)","If the module is remote, use its git ref form instead of a local absolute path"],"exampleFix":"// before\ndagger workspace client init --path=./client --sdk=go --module=/home/me/proj/shared\n// after\ndagger workspace client init --path=./client --sdk=go --module=./shared","handlingStrategy":"validation","validationCode":"// shell: only pass absolute module refs when working from a local checkout\n[ -d .git ] || [ -f dagger.toml ] || { echo 'use a workspace-relative module ref'; exit 1; }","typeGuard":"func isRelativeModuleRef(ref string) bool {\n\treturn ref != \"\" && !filepath.IsAbs(filepath.Clean(strings.ReplaceAll(ref, \"\\\\\", \"/\")))\n}","tryCatchPattern":null,"preventionTips":["Use workspace-relative or git module refs instead of absolute host paths","Only rely on absolute refs when the workspace is a real local directory on the host","Avoid absolute paths in scripted/CI invocations"],"tags":["dagger","module-ref","path-validation"],"backgroundTag":"absolute-path-requires-local-source","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"}