{"record":{"id":"da1a44d1fa7881a0","repo":"BoundaryML/baml","slug":"failed-open-source-s-w","errorCode":null,"errorMessage":"failed open source %s: %w","messagePattern":"failed open source (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_go/baml_go/lib_common.go","lineNumber":638,"sourceCode":"}\n\nfunc isHex(s string) bool {\n\tif len(s) == 0 {\n\t\treturn false\n\t}\n\tfor _, r := range s {\n\t\tif !((r >= '0' && r <= '9') || (r >= 'a' && r <= 'f') || (r >= 'A' && r <= 'F')) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc copyFile(src, dst string) (err error) {\n\tlogger.Debug(\"Attempting to copy file\", \"source\", src, \"destination\", dst)\n\tsource, err := os.Open(src)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed open source %s: %w\", src, err)\n\t}\n\tdefer source.Close()\n\n\tdestination, err := os.Create(dst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed create destination %s: %w\", dst, err)\n\t}\n\tdefer func() {\n\t\tcerr := destination.Close()\n\t\tif err == nil && cerr != nil {\n\t\t\terr = fmt.Errorf(\"failed close destination %s: %w\", dst, cerr)\n\t\t}\n\t}()\n\n\t_, err = io.Copy(destination, source)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed copying from %s to %s: %w\", src, dst, err)\n\t}","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_go/baml_go/lib_common.go#L620-L656","documentation":"Filesystem error in the Go client library's toolchain downloader: os.Open failed on the local source path while copying a file (part of staging the downloaded baml library). The wrapped os error in %w carries the OS-level reason (permissions, missing file); the path is echoed so the failing file is identifiable.","triggerScenarios":"os.Open(src) fails during the copy fallback — the temp file was deleted by a concurrent process or cleaner before the copy, or permissions on the temp file/dir changed.","commonSituations":"/tmp cleaner removing files mid-download, another concurrent download process racing on the same temp file, or running with a different umask/user than the downloader.","solutions":["Re-run the download to recreate the temp file","Ensure no concurrent process or temp-cleaner deletes files mid-install (use a private temp dir)","Check permissions on the temp directory","If this recurs, check disk health — odd ENOENT/EIO on fresh files can indicate disk issues"],"exampleFix":"// before: shared /tmp, cleaned by other processes\ntmpFile, _ := os.CreateTemp(\"/tmp\", \"baml-*\")\n// after: private temp dir owned by the process\ndir, _ := os.MkdirTemp(\"\", \"baml-dl\")\ntmpFile, _ := os.CreateTemp(dir, \"lib-*\")","handlingStrategy":"retry","validationCode":"if _, err := os.Stat(src); err != nil {\n    return fmt.Errorf(\"temp file missing before copy: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := install(); err != nil {\n    if strings.Contains(err.Error(), \"failed open source\") {\n        os.Remove(src); return install() // recreate temp and retry\n    }\n    return err\n}","preventionTips":["Use a private temp directory not swept by cleaners","Avoid concurrent installs sharing temp file names","Check temp dir permissions for the running user","Investigate recurring ENOENT on fresh temp files (disk/cleanup tooling)"],"tags":["filesystem","file-open","download","temp-file"],"backgroundTag":"file-open-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}