apache/iceberg · error · Exception
Neither version.txt nor git version exists
Error message
Neither version.txt nor git version exists
What it means
getJavadocVersion falls back to the git branch name for Javadoc versioning; if versionDetails() throws NullPointerException (no git metadata), it throws Exception stating that neither version.txt nor git version exists. The build environment lacks any version source.
Source
Thrown at build.gradle:1243
// bump the MINOR version and always set the PATCH version to 0
return matcher.group(1) + "." + (Integer.valueOf(matcher.group(2)) + 1) + ".0-SNAPSHOT"
}
return version
} catch (Exception e) {
throw new Exception("Neither version.txt nor git version exists: " + e.getMessage(), e)
}
}
String getJavadocVersion() {
if (versionFileExists()) {
return getVersionFromFile()
}
try {
// use the branch name in place of version in Javadoc
return versionDetails().branchName
} catch (NullPointerException e) {
throw new Exception("Neither version.txt nor git version exists")
}
}
apply from: 'jmh.gradle'
apply from: 'baseline.gradle'
apply from: 'deploy.gradle'
apply from: 'tasks.gradle'
project(':iceberg-bom') {
apply plugin: 'java-platform'
dependencies {
constraints {
// The Iceberg-Build builds for only one Scala version at a time, so the BOM would also
// only contain artifacts for that single Scala version. The following code ensures that
// the BOM references the artifacts for all Scala versions.
def sparkScalaPattern = ~"(.*)-([0-9][.][0-9]+)_([0-9][.][0-9]+)"
def sparkScalaVersions = [View on GitHub (pinned to 86d9c8fc54)
Solutions
- Ensure the workspace is a proper git checkout with branch information (unshallow if needed)
- Provide version.txt so the version file path is used instead of git
- Export CI branch info and ensure the gradle-git-version plugin can read it
- Verify GIT_BRANCH/branch environment for CI shallow clones
Example fix
// before: git fetch --depth=1 (no branch info) // after git fetch --unshallow && git checkout main
Defensive patterns
Strategy: validation
Validate before calling
if [ ! -d .git ] && ! git rev-parse --abbrev-ref HEAD 2>/dev/null; then echo "Git branch info unavailable; provide version.txt"; exit 1 fi
Prevention
- Avoid --depth=1 checkouts for builds needing version info
- Provide version.txt as a fallback for non-git builds
- Ensure CI exposes branch names to the build
When it happens
Trigger: Generating Javadoc (or any task invoking getJavadocVersion) in a directory without .git and without version.txt, where versionDetails branchName lookup fails with NPE.
Common situations: Source archives without git metadata; CI checkouts with depth=1 and detached head lacking branch info; nightly builds in stripped-down workspaces.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- This build must be run with JDK 17 or 21 but was executed wi
- Neither version.txt nor git version exists:
- Expected a Spark/Scala version combination in Gradle project
- Releases must be built with Java 17
- The JMH benchmarks must be run with JDK 17 or JDK 21
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/67260f6b5b5ad254.
Report an issue: GitHub.