{"record":{"id":"43c70e2f8b0ad601","repo":"rectorphp/rector","slug":"you-must-ensure-to-run-compile-from-composer-git-r","errorCode":null,"errorMessage":"You must ensure to run compile from composer git repository clone and that git binary is available.","messagePattern":"You must ensure to run compile from composer git repository clone and that git binary is available\\.","errorType":"exception","errorClass":"VersionException","httpStatus":null,"severity":"error","filePath":"src/Application/VersionResolver.php","lineNumber":56,"sourceCode":"        }\n        if ($tagExecOutput !== []) {\n            $tag = $tagExecOutput[0];\n            if ($tag !== '') {\n                return $tag;\n            }\n        }\n        exec('git log --pretty=\"%H\" -n1 HEAD', $commitHashExecOutput, $commitHashResultCode);\n        if ($commitHashResultCode !== 0) {\n            throw new VersionException('Ensure to run compile from composer git repository clone and that git binary is available.');\n        }\n        $version = trim($commitHashExecOutput[0]);\n        return trim($version, '\"');\n    }\n    public static function resolverReleaseDateTime(): DateTime\n    {\n        exec('git log -n1 --pretty=%ci HEAD', $output, $resultCode);\n        if ($resultCode !== self::SUCCESS_CODE) {\n            throw new VersionException('You must ensure to run compile from composer git repository clone and that git binary is available.');\n        }\n        return new DateTime(trim($output[0]));\n    }\n}\n","sourceCodeStart":38,"sourceCodeEnd":61,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/src/Application/VersionResolver.php#L38-L61","documentation":"VersionResolver::resolverReleaseDateTime() runs `git log -n1 --pretty=%ci HEAD` during the compile step to bake the RELEASE_DATE constant into the built phar. A non-zero exit code from git throws VersionException. Like the other VersionResolver errors, this only affects building Rector itself from source, not running an installed Rector.","triggerScenarios":"Calling resolverReleaseDateTime() (directly or via the compile script) where git cannot run: no .git directory (zip/tarball export), git missing from PATH, git blocked by sandbox policy, or corrupted repository metadata.","commonSituations":"Packaging Rector into a custom phar in a Docker stage that strips .git; minimal alpine build images without git; automated release tooling running outside the clone.","solutions":["Run the compile from inside a complete git clone with git available: git clone ... && build there","Install git in the build container and confirm git log -n1 --pretty=%ci HEAD works","Keep the .git directory in the build context (do not add it to .dockerignore for the compile stage)","For safe.directory errors, run git config --global --add safe.directory <path>"],"exampleFix":"# before: Docker build stage copies source without .git\nCOPY rector-src/ /app/  # .git excluded\nRUN php compile.php  # VersionException\n\n# after: clone inside the build stage\nRUN git clone --depth 1 https://github.com/rectorphp/rector.git /app/rector\nRUN php /app/rector/compile.php","handlingStrategy":"validation","validationCode":"exec('git log -n1 --pretty=%ci HEAD', $date, $code);\nif ($code !== 0) {\n    exit('Cannot resolve release date: build outside a git clone or git unavailable');\n}","typeGuard":null,"tryCatchPattern":"catch \\Rector\\Exception\\VersionException during compile; treat as environment failure (no .git / no git) and abort the packaging job with a clear cause instead of shipping a broken build.","preventionTips":["Keep .git in the compile stage (do not strip it in Docker COPY)","Pin a working git binary in the build image","Test the full compile path in CI regularly so environment drift is caught early"],"tags":["php","rector","git","build","compile","release-date"],"backgroundTag":"missing-git-repository","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}