{"record":{"id":"0db8cbea4da31c0f","repo":"apache/iceberg","slug":"neither-version-txt-nor-git-version-exists","errorCode":null,"errorMessage":"Neither version.txt nor git version exists: ","messagePattern":"Neither version\\.txt nor git version exists: ","errorType":"console","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"build.gradle","lineNumber":1230,"sourceCode":"\nString getProjectVersion() {\n  if (versionFileExists()) {\n    return getVersionFromFile()\n  }\n\n  try {\n    // we're fetching the version from the latest tag (prefixed with 'apache-iceberg-'),\n    // which can look like this: '0.13.0-2-g805400f0.dirty' but we're only interested in the MAJOR.MINOR.PATCH part\n    String version = gitVersion(prefix: 'apache-iceberg-')\n    Pattern pattern = Pattern.compile(\"^([0-9]+)\\\\.([0-9]+)\\\\.([0-9]+)(.*)?\\$\")\n    Matcher matcher = pattern.matcher(version)\n    if (matcher.matches()) {\n      // bump the MINOR version and always set the PATCH version to 0\n      return matcher.group(1) + \".\" + (Integer.valueOf(matcher.group(2)) + 1) + \".0-SNAPSHOT\"\n    }\n    return version\n  } catch (Exception e) {\n    throw new Exception(\"Neither version.txt nor git version exists: \" + e.getMessage(), e)\n  }\n}\n\nString getJavadocVersion() {\n  if (versionFileExists()) {\n    return getVersionFromFile()\n  }\n\n  try {\n    // use the branch name in place of version in Javadoc\n    return versionDetails().branchName\n  } catch (NullPointerException e) {\n    throw new Exception(\"Neither version.txt nor git version exists\")\n  }\n}\n\napply from: 'jmh.gradle'\napply from: 'baseline.gradle'","sourceCodeStart":1212,"sourceCodeEnd":1248,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/build.gradle#L1212-L1248","documentation":"The build computes the project version from version.txt or the git-derived version; if both are unavailable it throws Exception wrapping the underlying cause. Without a version source the Gradle build cannot proceed.","triggerScenarios":"Running Gradle in a source tree where version.txt is missing AND git metadata is absent/unreadable (e.g. a source tarball without .git, shallow clone issues, git describe failure).","commonSituations":"Building from a downloaded source archive instead of a git clone; corrupt or pruned git repo; running in a container that copied only source files.","solutions":["Clone the repository with git history (git clone, not a tarball)","Restore/create version.txt with the expected base version string","Fix git access in the build environment (full fetch, valid .git directory)","Check the wrapped cause message (e) for the underlying git failure"],"exampleFix":"// before: building from an extracted tarball without .git\n// after\ngit clone https://github.com/apache/iceberg.git && cd iceberg && ./gradlew build","handlingStrategy":"validation","validationCode":"if [ ! -f version.txt ] && [ ! -d .git ]; then\n  echo \"Need git checkout or version.txt\"; exit 1\nfi\n./gradlew build","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always build from a full git clone","Ship version.txt in source distributions","Verify CI checkouts preserve git metadata"],"tags":["gradle","build","version"],"backgroundTag":"file-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}