{"record":{"id":"37adc19d81f5433a","repo":"react/react","slug":"could-not-find-build-commit-sha-file-did-you-run","errorCode":null,"errorMessage":"Could not find build/COMMIT_SHA file. Did you run scripts/release/download-experimental-build.js script?","messagePattern":"Could not find build/COMMIT_SHA file\\. Did you run scripts/release/download-experimental-build\\.js script\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-devtools-extensions/utils.js","lineNumber":27,"sourceCode":"const {existsSync, readFileSync} = require('fs');\nconst {resolve} = require('path');\n\nconst GITHUB_URL = 'https://github.com/facebook/react';\n\nfunction getGitCommit() {\n  try {\n    return execSync('git show -s --no-show-signature --format=%h')\n      .toString()\n      .trim();\n  } catch (error) {\n    // Mozilla runs this command from a git archive.\n    // In that context, there is no Git context.\n    // Using the commit hash specified to download-experimental-build.js script as a fallback.\n\n    // Try to read from build/COMMIT_SHA file\n    const commitShaPath = resolve(__dirname, '..', '..', 'build', 'COMMIT_SHA');\n    if (!existsSync(commitShaPath)) {\n      throw new Error(\n        'Could not find build/COMMIT_SHA file. Did you run scripts/release/download-experimental-build.js script?',\n      );\n    }\n\n    try {\n      const commitHash = readFileSync(commitShaPath, 'utf8').trim();\n      // Return short hash (first 7 characters) to match abbreviated commit hash format\n      return commitHash.slice(0, 7);\n    } catch (readError) {\n      throw new Error(\n        `Failed to read build/COMMIT_SHA file: ${readError.message}`,\n      );\n    }\n  }\n}\n\nfunction getVersionString(packageVersion = null) {\n  if (packageVersion == null) {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/react/react/blob/22e4f993c7ce9373c95aef093b003f84249e2045/packages/react-devtools-extensions/utils.js#L9-L45","documentation":"To produce a build version string, `utils.js` first tries `git show` for the commit hash. In an environment without git context (e.g. Mozilla's git-archive build), it falls back to reading `build/COMMIT_SHA`. If that file does not exist, it throws pointing at `scripts/release/download-experimental-build.js`, which is what writes the file during experimental-build packaging.","triggerScenarios":"Running the DevTools extension build (Yarn scripts that call `getVersionString`/commit-hash helpers) outside a git checkout AND without having first run the experimental-build download script. CI environments that use a git archive (no `.git`) and skip the download step.","commonSituations":"Building the Firefox extension from a Mozilla source archive. Building from a tarball release rather than a git clone. Fresh clone where `build/` was never populated.","solutions":["Run `node scripts/release/download-experimental-build.js` (per your release flow) to write `build/COMMIT_SHA` before building.","If building from a real checkout, ensure the build runs inside the git repo so the `git show` fallback succeeds.","Manually create `build/COMMIT_SHA` containing the desired commit hash as a last resort."],"exampleFix":"# before\nyarn build:extension   # build/COMMIT_SHA missing → throws\n\n# after\nnode scripts/release/download-experimental-build.js\nyarn build:extension","handlingStrategy":"validation","validationCode":"import {existsSync} from 'fs';\nimport {resolve} from 'path';\n\nfunction ensureCommitSha() {\n  const p = resolve(__dirname, '..', '..', 'build', 'COMMIT_SHA');\n  if (!existsSync(p)) {\n    throw new Error(\n      'Missing build/COMMIT_SHA. Run: node scripts/release/download-experimental-build.js',\n    );\n  }\n  return p;\n}","typeGuard":"function hasCommitShaFile(dir) {\n  return existsSync(resolve(dir, 'build', 'COMMIT_SHA'));\n}","tryCatchPattern":"try {\n  version = getVersionString();\n} catch (e) {\n  if (e?.message?.includes('COMMIT_SHA')) {\n    console.error('Run scripts/release/download-experimental-build.js first.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Run the download-experimental-build script before building the extension in non-git contexts.","Build inside a real git checkout when possible so the git fallback works.","Add a CI precondition check for build/COMMIT_SHA in archive-based builds."],"tags":["react-devtools","build","release","git","configuration"],"backgroundTag":null,"analyzedSha":"22e4f993c7ce9373c95aef093b003f84249e2045","analyzedAt":"2026-08-12T22:33:25.580Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}