gastownhall/beads · error

failed to get current directory: %v

Error message

failed to get current directory: %v

What it means

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/.

Source

Thrown at cmd/bd/init_proxied_server.go:95

	if in.externalConfig == nil {
		// in.quiet, not the global quietFlag: init's local --quiet shadows
		// the persistent flag, so the global is false under `bd init -q`.
		if _, err := resolveAndProbeDolt(ctx, "bd init --proxied-server", in.quiet || quietFlag); err != nil {
			return err
		}
	}

	if err := config.Initialize(); err != nil {
		fmt.Fprintf(os.Stderr, "Warning: failed to initialize config: %v\n", err)
	}

	if err := checkExistingBeadsData(in.prefix); err != nil {
		return err
	}

	cwd, err := os.Getwd()
	if err != nil {
		return fmt.Errorf("failed to get current directory: %v", err)
	}

	fsProvider := fs.NewFileSystemProvider(cwd, newBeadsDirTemplates(), newFileSystemAdapters())
	fsUseCase := fsProvider.BeadsDirFSUseCase()
	gitUC := git.NewGitProvider(cwd).GitUseCase()

	if in.stealth {
		if err := fsUseCase.SetupStealthMode(ctx, !in.quiet); err != nil {
			return fmt.Errorf("setting up stealth mode: %v", err)
		}
		in.skipHooks = true
	}

	prefix, err := resolveInitPrefix(in.prefix)
	if err != nil {
		return err
	}

View on GitHub (pinned to 71377f2769)

Solutions

  1. 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`.
  2. Verify the directory exists: `pwd` should succeed without 'No such file or directory'.
  3. In scripts, ensure no parallel step deletes the workspace before init runs.

Example fix

// before
rm -rf old-workspace  # shell still inside it
bd init --proxied-server  # failed to get current directory
// after
cd /path/to/repo
bd init --proxied-server
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Getwd(); err != nil {
    return fmt.Errorf("current working directory no longer exists: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/496053e8802ea2d0. Report an issue: GitHub.