{"record":{"id":"b1c9580cb7a94e16","repo":"GoogleContainerTools/skaffold","slug":"finding-current-directory-w","errorCode":null,"errorMessage":"finding current directory: %w","messagePattern":"finding current directory: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/runcontext/context.go","lineNumber":411,"sourceCode":"\tfor _, cfg := range configs {\n\t\tif cfg != nil {\n\t\t\tpipeline := cfg.(*latest.SkaffoldConfig).Pipeline\n\t\t\tcfgName := getConfigName(cfg.(*latest.SkaffoldConfig).Metadata.Name)\n\t\t\tpipelines[cfgName] = pipeline\n\t\t\torderedConfigs = append(orderedConfigs, cfgName)\n\t\t}\n\t}\n\tkubeConfig, err := kubectx.CurrentConfig()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting current cluster context: %w\", err)\n\t}\n\tkubeContext := kubeConfig.CurrentContext\n\tlog.Entry(context.TODO()).Infof(\"Using kubectl context: %s\", kubeContext)\n\n\t// TODO(dgageot): this should be the folder containing skaffold.yaml. Should also be moved elsewhere.\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"finding current directory: %w\", err)\n\t}\n\n\t// combine all provided lists of insecure registries into a map\n\tcfgRegistries, err := config.GetInsecureRegistries(opts.GlobalConfig)\n\tif err != nil {\n\t\tlog.Entry(context.TODO()).Warn(\"error retrieving insecure registries from global config: push/pull issues may exist...\")\n\t}\n\tvar regList []string\n\tregList = append(regList, opts.InsecureRegistries...)\n\tfor _, cfgName := range orderedConfigs {\n\t\tcfg := pipelines[cfgName]\n\t\tregList = append(regList, cfg.Build.InsecureRegistries...)\n\t}\n\tregList = append(regList, cfgRegistries...)\n\tinsecureRegistries := make(map[string]bool, len(regList))\n\tfor _, r := range regList {\n\t\tinsecureRegistries[r] = true\n\t}","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/runcontext/context.go#L393-L429","documentation":"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\".","triggerScenarios":"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.","commonSituations":"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.","solutions":["cd back to an existing directory (e.g. the project root) and re-run the command","Recreate the deleted directory if the shell is stuck inside it","Open a fresh terminal/shell session","Check filesystem mount/permission issues if the directory exists but is inaccessible"],"exampleFix":"// before: running from a deleted dir\n$ cd /tmp/build-123  # deleted by CI\ncd - && skaffold dev\n// after\n$ cd /path/to/project && skaffold dev","handlingStrategy":"try-catch","validationCode":"if _, err := os.Getwd(); err != nil { return errors.New(\"current working directory no longer exists; cd to a valid directory first\") }","typeGuard":null,"tryCatchPattern":"runCtx, err := GetRunContext(config, opts)\nif err != nil && strings.Contains(err.Error(), \"finding current directory\") {\n    return nil, errors.New(\"re-run from an existing project directory\")\n}\nreturn runCtx, err","preventionTips":["Don't launch skaffold from tmp/build dirs subject to cleanup","Re-cd into the project root after cleanup scripts run","Use absolute --filepath/config paths so cwd matters less"],"tags":["skaffold","go","filesystem","working-directory"],"backgroundTag":"working-directory-missing","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}