apache/iceberg · error · Exception

Neither version.txt nor git version exists:

Error message

Neither version.txt nor git version exists: 

What it means

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.

Source

Thrown at build.gradle:1230

String getProjectVersion() {
  if (versionFileExists()) {
    return getVersionFromFile()
  }

  try {
    // we're fetching the version from the latest tag (prefixed with 'apache-iceberg-'),
    // which can look like this: '0.13.0-2-g805400f0.dirty' but we're only interested in the MAJOR.MINOR.PATCH part
    String version = gitVersion(prefix: 'apache-iceberg-')
    Pattern pattern = Pattern.compile("^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?\$")
    Matcher matcher = pattern.matcher(version)
    if (matcher.matches()) {
      // 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'

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Clone the repository with git history (git clone, not a tarball)
  2. Restore/create version.txt with the expected base version string
  3. Fix git access in the build environment (full fetch, valid .git directory)
  4. Check the wrapped cause message (e) for the underlying git failure

Example fix

// before: building from an extracted tarball without .git
// after
git clone https://github.com/apache/iceberg.git && cd iceberg && ./gradlew build
Defensive patterns

Strategy: validation

Validate before calling

if [ ! -f version.txt ] && [ ! -d .git ]; then
  echo "Need git checkout or version.txt"; exit 1
fi
./gradlew build

Prevention

When it happens

Trigger: 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).

Common situations: 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.

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


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/0db8cbea4da31c0f. Report an issue: GitHub.