{"record":{"id":"c19a78eec4f56192","repo":"paperclipai/paperclip","slug":"pinned-opencode-source-executable-is-not-a-regular","errorCode":null,"errorMessage":"Pinned OpenCode source executable is not a regular file","messagePattern":"Pinned OpenCode source executable is not a regular file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/scripts/materialize-opencode-binary.mjs","lineNumber":60,"sourceCode":"  if (platform !== \"linux\" || architecture !== \"x64\") {\n    throw new Error(\n      `Pinned OpenCode materialization requires linux/x64, received ${platform}/${architecture}`,\n    );\n  }\n\n  const packageRoot = realpathSync(\n    options.packageRoot ??\n      resolve(import.meta.dirname, \"../node_modules/opencode-ai\"),\n  );\n  const dependencyRoot = dirname(packageRoot);\n  const baselineRoot = realpathSync(join(dependencyRoot, BASELINE_PACKAGE));\n  assertPackage(packageRoot, \"opencode-ai\");\n  assertPackage(baselineRoot, BASELINE_PACKAGE);\n\n  const source = join(baselineRoot, \"bin\", \"opencode\");\n  const target = join(packageRoot, \"bin\", \"opencode.exe\");\n  if (!lstatSync(source).isFile()) {\n    throw new Error(\"Pinned OpenCode source executable is not a regular file\");\n  }\n  if (existsSync(target)) {\n    if (!lstatSync(target).isFile()) {\n      throw new Error(\"OpenCode target executable is not a regular file\");\n    }\n    unlinkSync(target);\n  }\n  try {\n    linkSync(source, target);\n  } catch (error) {\n    const code = error?.code;\n    if (!new Set([\"EACCES\", \"EMLINK\", \"EPERM\", \"EXDEV\"]).has(code)) {\n      throw error;\n    }\n    copyFileSync(source, target);\n  }\n  chmodSync(target, 0o755);\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/paperclip-runner/scripts/materialize-opencode-binary.mjs#L42-L78","documentation":"Before hard-linking, the script verifies the baseline OpenCode executable at <baselineRoot>/bin/opencode is a regular file. If lstat reports anything else (directory, symlink, etc.), materialization aborts because the hard-link source is not a usable executable.","triggerScenarios":"The baseline package's bin/opencode is missing or is a symlink (e.g. a package-manager bin shim), a directory, or otherwise not a regular file when materializePinnedOpenCodeBinary runs.","commonSituations":"A package manager installed opencode with a symlinked bin shim; the baseline package was partially installed (postinstall skipped); a broken extraction left bin/opencode as a directory.","solutions":["Inspect 'ls -la <baselineRoot>/bin/opencode' — reinstall the baseline package so bin/opencode is a real regular file.","If the installer created a symlink shim, point baselineRoot at the package containing the real binary.","Reinstall the pinned baseline package (rm -rf node_modules/<baseline> && pnpm install) to restore a proper binary.","Check that the correct BASELINE_PACKAGE root is being passed, not the target package root."],"exampleFix":"# before: bin/opencode is a symlink shim\n$ rm -rf node_modules/<baseline-package> && pnpm install\n$ node scripts/materialize-opencode-binary.mjs","handlingStrategy":"validation","validationCode":"import { lstatSync } from 'node:fs';\nconst st = lstatSync(join(baselineRoot, 'bin', 'opencode'));\nif (!st.isFile()) throw new Error('baseline bin/opencode must be a regular file (got symlink/dir?)');","typeGuard":"function isRegularFileSync(p) {\n  try { return lstatSync(p).isFile(); } catch { return false; }\n}","tryCatchPattern":"try {\n  materializePinnedOpenCodeBinary();\n} catch (err) {\n  if (err.message === 'Pinned OpenCode source executable is not a regular file') {\n    execSync(`pnpm install --force`);\n    materializePinnedOpenCodeBinary();\n  } else throw err;\n}","preventionTips":["Reinstall the baseline package if its bin shim is a symlink.","Verify baseline integrity (pnpm why) after dependency changes.","Dereference package-manager bin shims before pointing baselineRoot at them.","Run postinstall scripts so binaries are fully materialized."],"tags":["filesystem","validation","binary"],"backgroundTag":"incompatible-source-type","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}