{"record":{"id":"fae8b1006816ec8b","repo":"dagger/dagger","slug":"failed-to-pack-git-checkout-for-q-w","errorCode":null,"errorMessage":"failed to pack git checkout for %q: %w","messagePattern":"failed to pack git checkout for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/schema/host.go","lineNumber":849,"sourceCode":"\tif err != nil {\n\t\treturn inst, err\n\t}\n\tbk, err := query.Engine(ctx)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to get engine client: %w\", err)\n\t}\n\n\t// args.StateDigest is deliberately unused in the body: it is a pure dagql\n\t// cache key, keying this reconstruction to the checkout's ref state so the\n\t// result is reused until the checkout's refs move.\n\n\texpectedStateDigest := \"\"\n\tif args.ValidateState {\n\t\texpectedStateDigest = args.StateDigest\n\t}\n\tpack, err := bk.PackGitCheckout(ctx, args.Path, expectedStateDigest)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to pack git checkout for %q: %w\", args.Path, err)\n\t}\n\tdefer func() { _ = pack.Close() }()\n\n\tdir, err := core.MaterializeGitCheckoutPack(ctx, pack)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to materialize git checkout pack for %q: %w\", args.Path, err)\n\t}\n\n\tsrv, err := core.CurrentDagqlServer(ctx)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to get current dagql server: %w\", err)\n\t}\n\treturn dagql.NewObjectResultForCurrentCall(ctx, srv, dir)\n}\n\ntype hostServiceArgs struct {\n\tHost  string `default:\"localhost\"`\n\tPorts []dagql.InputObject[core.PortForward]","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/schema/host.go#L831-L867","documentation":"Returned by gitDir in core/schema/host.go when the engine asks the client to pack the git checkout at args.Path (bk.PackGitCheckout) and that fails. The client-side git acts as the oracle for the checkout: this covers the path not being a git repository, git not being installed, the checkout being dirty, or a state-digest mismatch when ValidateState is set. The path is included in the message.","triggerScenarios":"Host.directory with gitDir reconstruction on: (a) a path that is not inside a git work tree; (b) a machine without git on PATH; (c) a checkout whose refs/state moved so expectedStateDigest no longer matches when args.ValidateState is true; (d) unreadable .git directory.","commonSituations":"Pointing Dagger at a subdirectory downloaded without .git (zip/tarball extract); shallow or partially cloned repos with unusual states; CI checkouts reusing a stale digest after a rebase/force-push changed refs; missing git in minimal containers running the client.","solutions":["Run inside an actual git clone ('git clone' the repo, don't unzip an archive) and verify 'git rev-parse --is-inside-work-tree' succeeds in the path","Install git in the environment running the Dagger client ('apt-get install git' / 'apk add git')","If ValidateState is used and refs moved, refresh the state digest from the current checkout (re-run the client so it recomputes) or disable strict validation","Check permissions on the path/.git so the client user can read them"],"exampleFix":"// before\n# pipeline unzips source.zip and points Host.directory at it\nHost.directory(\"./source\") // not a git repo -> pack fails\n// after\n# clone properly so .git exists\ngit clone https://github.com/org/repo.git source && dagger run ./pipeline # Host.directory(\"./source\")","handlingStrategy":"validation","validationCode":"func isGitWorkTree(path string) error {\n    cmd := exec.Command(\"git\", \"-C\", path, \"rev-parse\", \"--is-inside-work-tree\")\n    if out, err := cmd.Output(); err != nil || strings.TrimSpace(string(out)) != \"true\" {\n        return fmt.Errorf(\"%s is not a git work tree (clone it instead of extracting an archive)\", path)\n    }\n    if _, err := exec.LookPath(\"git\"); err != nil {\n        return fmt.Errorf(\"git is not installed on the client host\")\n    }\n    return nil\n}\n// call isGitWorkTree(path) before Host.directory(path)","typeGuard":null,"tryCatchPattern":"dir, err := client.Host().Directory(path)\nif err != nil && strings.Contains(err.Error(), \"failed to pack git checkout\") {\n    // path is not a git repo, git missing, or state digest stale: clone properly / refresh digest\n}","preventionTips":["Always run against real git clones, never zip/tarball extracts","Install git in any minimal environment running the Dagger client","Recompute state digests after rebase/force-push; don't reuse stale digests with ValidateState","Check read permissions on the path and .git before invoking"],"tags":["git","filesystem","dagger"],"backgroundTag":"git-checkout-pack-failed","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"}