{"record":{"id":"5ce47b35e78d91f6","repo":"github/copilot-sdk","slug":"checking-existing-s-permissions-w","errorCode":null,"errorMessage":"checking existing %s permissions: %w","messagePattern":"checking existing (.+?) permissions: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/internal/embeddedcli/embeddedcli.go","lineNumber":456,"sourceCode":"\tif err := installVerifiedFile(wrapperPath, config.RuntimeExecutable, config.RuntimeExecutableHash, 0755, \"runtime wrapper\"); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn wrapperPath, nil\n}\n\nfunc installVerifiedFile(path string, reader io.Reader, expectedHash []byte, mode os.FileMode, label string) error {\n\tif _, err := os.Stat(path); err == nil {\n\t\texistingHash, err := hashFile(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"hashing existing %s: %w\", label, err)\n\t\t}\n\t\tif !bytes.Equal(existingHash, expectedHash) {\n\t\t\treturn fmt.Errorf(\"existing %s hash mismatch\", label)\n\t\t}\n\t\tif runtime.GOOS != \"windows\" && mode.Perm()&0111 != 0 {\n\t\t\tinfo, err := os.Stat(path)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"checking existing %s permissions: %w\", label, err)\n\t\t\t}\n\t\t\tif info.Mode().Perm()&0111 == 0 {\n\t\t\t\tif err := os.Chmod(path, info.Mode().Perm()|mode.Perm()&0111); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"restoring existing %s permissions: %w\", label, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\ttmp, err := os.CreateTemp(filepath.Dir(path), \".copilot-runtime-pair-*.tmp\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating temporary %s: %w\", label, err)\n\t}\n\ttmpPath := tmp.Name()\n\th := sha256.New()\n\t_, err = io.Copy(io.MultiWriter(tmp, h), reader)\n\tif err1 := tmp.Chmod(mode); err1 != nil && err == nil {","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/internal/embeddedcli/embeddedcli.go#L438-L474","documentation":"When an existing file matches the expected hash, installVerifiedFile still ensures it is executable on non-Windows platforms. This error wraps an os.Stat failure that occurs while re-checking the existing file's permissions after the hash check succeeded.","triggerScenarios":"os.Stat(path) fails in the permission-restoration branch — the file was removed or became inaccessible between the initial Stat/hashFile and this second Stat.","commonSituations":"A concurrent process deleting or replacing the installed binary mid-install; a race between two simultaneous installs into the same directory.","solutions":["Serialize installs — don't run two installs into the same installDir concurrently.","Re-run the install; the file will be rewritten since it no longer exists.","Check what external process (e.g. a cleaner/AV) removes files from the install directory."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := client.InstallAt(dir)\nif err != nil && strings.Contains(err.Error(), \"checking existing\") {\n    time.Sleep(100 * time.Millisecond)\n    err = client.InstallAt(dir) // transient race: file vanished mid-install\n}","preventionTips":["Serialize installs to the same directory with a lock","Avoid running concurrent app instances during first-run install"],"tags":["filesystem","permissions","race-condition"],"backgroundTag":"permission-denied","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}