{"record":{"id":"a23db484e1ca4395","repo":"tailscale/tailscale","slug":"locale-error-w","errorCode":null,"errorMessage":"locale error: %w","messagePattern":"locale error: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/qrcodes/qrcodes_linux.go","lineNumber":98,"sourceCode":"\t\tformat = FormatSmall\n\t}\n\n\treturn format, nil\n}\n\nfunc locale() (map[string]string, error) {\n\tlocale := map[string]string{\n\t\t\"LANG\":     os.Getenv(\"LANG\"),\n\t\t\"LC_CTYPE\": os.Getenv(\"LC_CTYPE\"),\n\t}\n\n\tcmd := exec.Command(\"locale\")\n\tout, err := cmd.Output()\n\tif err != nil {\n\t\tif errors.Is(err, exec.ErrNotFound) {\n\t\t\treturn locale, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"locale error: %w\", err)\n\t}\n\n\tfor line := range strings.SplitSeq(string(out), \"\\n\") {\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tk, v, found := strings.Cut(line, \"=\")\n\t\tif !found {\n\t\t\tcontinue\n\t\t}\n\t\tv, err := strconv.Unquote(v)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\t\tlocale[k] = v\n\t}\n\treturn locale, nil\n}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/tailscale/tailscale/blob/6e0912f97994f927632b34ae9e63b53d6516a6ac/util/qrcodes/qrcodes_linux.go#L80-L116","documentation":"Fired in locale() when running the external `locale` command fails with an error other than exec.ErrNotFound (the binary exists but exited non-zero, or exec failed for another reason); LANG/LC_CTYPE detection fails, so callers cannot determine UTF-8 support.","triggerScenarios":"Thrown at util/qrcodes/qrcodes_linux.go:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rely on the pre-populated env-var values (LANG/LC_CTYPE) as fallback","Check why `locale` exits non-zero in the environment","Treat locale detection as best-effort and skip errors"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6e0912f97994f927632b34ae9e63b53d6516a6ac","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}