{"record":{"id":"0b1fbd79abf91d6c","repo":"charmbracelet/glow","slug":"unable-to-get-absolute-path-w","errorCode":null,"errorMessage":"unable to get absolute path: %w","messagePattern":"unable to get absolute path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":147,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\n\t\tif src != nil {\n\t\t\treturn src, nil\n\t\t}\n\n\t\treturn nil, errors.New(\"missing markdown source\")\n\t}\n\n\tr, err := os.Open(arg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to open file: %w\", err)\n\t}\n\tu, err := filepath.Abs(arg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get absolute path: %w\", err)\n\t}\n\treturn &source{r, u}, nil\n}\n\n// validateStyle checks if the style is a default style, if not, checks that\n// the custom style exists.\nfunc validateStyle(style string) error {\n\tif style != \"auto\" && styles.DefaultStyles[style] == nil {\n\t\tstyle = utils.ExpandPath(style)\n\t\tif _, err := os.Stat(style); errors.Is(err, fs.ErrNotExist) {\n\t\t\treturn fmt.Errorf(\"specified style does not exist: %s\", style)\n\t\t} else if err != nil {\n\t\t\treturn fmt.Errorf(\"unable to stat file: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/main.go#L129-L165","documentation":"After successfully opening the file, glow labels the source with filepath.Abs(arg), which resolves the path relative to the current working directory. filepath.Abs only fails when os.Getwd() fails - i.e. the process's current directory was deleted, renamed, or became unreadable. This is an extremely rare condition distinct from any problem with the file itself.","triggerScenarios":"The directory glow was started in is deleted (rm -rf) while the process runs; the cwd's permissions are revoked; the cwd sits on an unmounted/dead filesystem.","commonSituations":"Scripts that delete their working directory before invoking tools, containers where the workdir is removed by another process, long-lived shells in cleaned-up temp dirs.","solutions":["Check that the current directory still exists: pwd","Re-run glow from a valid directory (cd to a stable path first)","In scripts, avoid deleting the working directory while tools still run from it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func cwdValid() bool {\n\twd, err := os.Getwd()\n\treturn err == nil && wd != \"\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never delete the current working directory of a running shell or script","In scripts, cd to a stable directory before invoking external tools"],"tags":["filesystem","cwd","rare"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}