{"record":{"id":"7b68bf2769c1fcbe","repo":"asdf-vm/asdf","slug":"unable-to-fetch-current-directory-w","errorCode":null,"errorMessage":"unable to fetch current directory: %w","messagePattern":"unable to fetch current directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/cli.go","lineNumber":1096,"sourceCode":"\tif err != nil {\n\t\tlogger.Printf(\"failed to update %s due to error: %s\\n\", pluginName, err)\n\n\t\treturn\n\t}\n\n\tlogger.Printf(\"updated %s to ref %s\\n\", pluginName, updatedToRef)\n}\n\nfunc installCommand(logger *log.Logger, toolName, version string, keepDownload bool) error {\n\tconf, err := config.LoadConfig()\n\tif err != nil {\n\t\tlogger.Printf(\"error loading config: %s\", err)\n\t\treturn err\n\t}\n\n\tdir, err := os.Getwd()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to fetch current directory: %w\", err)\n\t}\n\n\tif toolName == \"\" {\n\t\t// Install all versions\n\t\terrs := versions.InstallAll(conf, dir, os.Stdout, os.Stderr)\n\t\tif len(errs) > 0 {\n\t\t\tfor _, err := range errs {\n\t\t\t\t// Don't print error if no version set, this just means the current\n\t\t\t\t// dir doesn't use a particular plugin that is installed.\n\t\t\t\tif _, ok := err.(versions.NoVersionSetError); ok {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif _, ok := err.(versions.UninstallableVersionError); ok {\n\t\t\t\t\tmsg := fmt.Sprintf(\"skipping %s\\n\", err.Error())\n\t\t\t\t\tos.Stderr.Write([]byte(msg))\n\t\t\t\t\tcontinue\n\t\t\t\t}","sourceCodeStart":1078,"sourceCodeEnd":1114,"githubUrl":"https://github.com/asdf-vm/asdf/blob/074a1722ca88d6677f228541ce06efaf4f9924d4/internal/cli/cli.go#L1078-L1114","documentation":"installCommand calls os.Getwd() to determine the directory whose .tool-versions should drive installation. If the current working directory cannot be determined (e.g. it was deleted or lacks permissions), the error is wrapped as \"unable to fetch current directory\".","triggerScenarios":"Running `asdf install` (or `asdf install <tool> <version>`) from a directory that has been deleted while the shell still sits in it, or a directory the user cannot stat.","commonSituations":"Another terminal/process removed the working directory (common after checking out/cleaning build dirs); running inside a container where the mount disappeared; permission churn on the cwd.","solutions":["`cd` to a valid existing directory (e.g. `cd $(pwd -P)` or cd out and back in) and retry.","Recreate the deleted directory or restore its mount.","Check filesystem permissions on the current directory.","Use `asdf install <plugin> <version>` with explicit tool/version from a valid directory."],"exampleFix":"# before (cwd deleted)\nasdf install\n# after\ncd /path/to/project && asdf install","handlingStrategy":"validation","validationCode":"if [ ! -d \"$(pwd)\" ]; then echo \"cwd invalid\"; exit 1; fi\nasdf install","typeGuard":null,"tryCatchPattern":"if ! asdf install 2>&1 | grep -q 'unable to fetch current directory'; then :; else cd \"$PROJECT_DIR\" && asdf install; fi","preventionTips":["cd out and back (or `cd -P .`) after external processes may delete the cwd","Avoid removing directories while shells sit inside them","Use `cd /path && asdf install` in scripts instead of relying on inherited cwd"],"tags":["filesystem","working-directory","os"],"backgroundTag":"working-directory-unavailable","analyzedSha":"074a1722ca88d6677f228541ce06efaf4f9924d4","analyzedAt":"2026-08-30T19:56:42.972Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}