GoogleContainerTools/skaffold · error

finding current directory: %w

Error message

finding current directory: %w

What it means

GetRunContext calls os.Getwd() to record the current working directory (used for resolving relative paths like contexts and manifests). If the OS call fails — typically because the process's working directory was deleted — the error is wrapped as "finding current directory: %w".

Source

Thrown at pkg/skaffold/runner/runcontext/context.go:411

	for _, cfg := range configs {
		if cfg != nil {
			pipeline := cfg.(*latest.SkaffoldConfig).Pipeline
			cfgName := getConfigName(cfg.(*latest.SkaffoldConfig).Metadata.Name)
			pipelines[cfgName] = pipeline
			orderedConfigs = append(orderedConfigs, cfgName)
		}
	}
	kubeConfig, err := kubectx.CurrentConfig()
	if err != nil {
		return nil, fmt.Errorf("getting current cluster context: %w", err)
	}
	kubeContext := kubeConfig.CurrentContext
	log.Entry(context.TODO()).Infof("Using kubectl context: %s", kubeContext)

	// TODO(dgageot): this should be the folder containing skaffold.yaml. Should also be moved elsewhere.
	cwd, err := os.Getwd()
	if err != nil {
		return nil, fmt.Errorf("finding current directory: %w", err)
	}

	// combine all provided lists of insecure registries into a map
	cfgRegistries, err := config.GetInsecureRegistries(opts.GlobalConfig)
	if err != nil {
		log.Entry(context.TODO()).Warn("error retrieving insecure registries from global config: push/pull issues may exist...")
	}
	var regList []string
	regList = append(regList, opts.InsecureRegistries...)
	for _, cfgName := range orderedConfigs {
		cfg := pipelines[cfgName]
		regList = append(regList, cfg.Build.InsecureRegistries...)
	}
	regList = append(regList, cfgRegistries...)
	insecureRegistries := make(map[string]bool, len(regList))
	for _, r := range regList {
		insecureRegistries[r] = true
	}

View on GitHub (pinned to a1189de023)

Solutions

  1. cd back to an existing directory (e.g. the project root) and re-run the command
  2. Recreate the deleted directory if the shell is stuck inside it
  3. Open a fresh terminal/shell session
  4. Check filesystem mount/permission issues if the directory exists but is inaccessible

Example fix

// before: running from a deleted dir
$ cd /tmp/build-123  # deleted by CI
cd - && skaffold dev
// after
$ cd /path/to/project && skaffold dev
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Getwd(); err != nil { return errors.New("current working directory no longer exists; cd to a valid directory first") }

Try / catch

runCtx, err := GetRunContext(config, opts)
if err != nil && strings.Contains(err.Error(), "finding current directory") {
    return nil, errors.New("re-run from an existing project directory")
}
return runCtx, err

Prevention

When it happens

Trigger: Calling any skaffold command that builds a RunContext from a directory that no longer exists on disk (deleted or renamed after the shell entered it), or extreme permission restrictions on the cwd.

Common situations: Running skaffold from a tmp dir removed by a cleanup job, a terminal still cd'ed into a deleted build output folder, or containers/CI workspaces pruned mid-run.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/b1c9580cb7a94e16. Report an issue: GitHub.