{"record":{"id":"496053e8802ea2d0","repo":"gastownhall/beads","slug":"failed-to-get-current-directory-v-496053","errorCode":null,"errorMessage":"failed to get current directory: %v","messagePattern":"failed to get current directory: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init_proxied_server.go","lineNumber":95,"sourceCode":"\tif in.externalConfig == nil {\n\t\t// in.quiet, not the global quietFlag: init's local --quiet shadows\n\t\t// the persistent flag, so the global is false under `bd init -q`.\n\t\tif _, err := resolveAndProbeDolt(ctx, \"bd init --proxied-server\", in.quiet || quietFlag); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif err := config.Initialize(); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to initialize config: %v\\n\", err)\n\t}\n\n\tif err := checkExistingBeadsData(in.prefix); err != nil {\n\t\treturn err\n\t}\n\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get current directory: %v\", err)\n\t}\n\n\tfsProvider := fs.NewFileSystemProvider(cwd, newBeadsDirTemplates(), newFileSystemAdapters())\n\tfsUseCase := fsProvider.BeadsDirFSUseCase()\n\tgitUC := git.NewGitProvider(cwd).GitUseCase()\n\n\tif in.stealth {\n\t\tif err := fsUseCase.SetupStealthMode(ctx, !in.quiet); err != nil {\n\t\t\treturn fmt.Errorf(\"setting up stealth mode: %v\", err)\n\t\t}\n\t\tin.skipHooks = true\n\t}\n\n\tprefix, err := resolveInitPrefix(in.prefix)\n\tif err != nil {\n\t\treturn err\n\t}\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init_proxied_server.go#L77-L113","documentation":"After preflight checks, runInitProxiedServer calls os.Getwd() to determine the working directory used to construct the filesystem and git providers. If the current working directory cannot be determined (it was deleted), the error is wrapped with this message and proxied-server init aborts before creating .beads/.","triggerScenarios":"os.Getwd() fails because the process's current directory was removed or renamed while the shell/CLI was running, or on systems where the cwd is inaccessible due to permissions.","commonSituations":"Running `bd init --proxied-server` from a terminal whose working directory was deleted (e.g. by a build clean step or container restart), or in ephemeral CI workspaces removed mid-run.","solutions":["cd to an existing directory (or reopen the shell in the repo) and re-run the command: `cd /path/to/repo && bd init --proxied-server`.","Verify the directory exists: `pwd` should succeed without 'No such file or directory'.","In scripts, ensure no parallel step deletes the workspace before init runs."],"exampleFix":"// before\nrm -rf old-workspace  # shell still inside it\nbd init --proxied-server  # failed to get current directory\n// after\ncd /path/to/repo\nbd init --proxied-server","handlingStrategy":"validation","validationCode":"if _, err := os.Getwd(); err != nil {\n    return fmt.Errorf(\"current working directory no longer exists: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always cd into the target repo immediately before running bd init.","Avoid running init from shells whose cwd was deleted by cleanup steps.","In CI, ensure workspace directories persist until init completes.","If you see 'shell-init: error retrieving current directory', reopen the shell."],"tags":["filesystem","init","cli"],"backgroundTag":"working-directory-missing","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}