abhigyanpatwari/GitNexus · error · Error

GitNexus package version is unavailable in ${packageRoot}

Error message

GitNexus package version is unavailable in ${packageRoot}

What it means

Thrown after dependency collection when the root package's manifest (dependencyInputs.packages[0].manifest, i.e. the packageRoot's own package.json) has no usable string `version` field. The analyzer identity embeds the package version as cliVersion, so an absent or non-string version is a hard failure rather than a silent placeholder.

Source

Thrown at gitnexus/src/core/analyzer-identity.ts:2729

        rememberIdentityCache(previousCache);
        return cachedIdentity;
      }
    }
  }

  const build = hashBuildTree(buildRoot, previousCache, options, traversalLimits);
  const dependencyInputs = collectDependencyInputs(packageRoot, options, traversalLimits);
  const dependencySnapshotBefore = dependencySnapshot(dependencyInputs);
  const dependency = hashDependencyRuntime(
    dependencyInputs,
    previousCache,
    options,
    runtimeVariant,
  );

  const packageVersion = dependencyInputs.packages[0]?.manifest.version;
  if (typeof packageVersion !== 'string' || packageVersion.trim() === '') {
    throw new Error(`GitNexus package version is unavailable in ${packageRoot}`);
  }

  const buildSnapshotAfter = buildSnapshot(
    collectBuildEntries(buildRoot, options, traversalLimits),
  );
  if (!isDeepStrictEqual(build.snapshot, buildSnapshotAfter)) {
    throw new Error(`Analyzer build changed while its identity was being computed: ${buildRoot}`);
  }
  const dependencySnapshotAfter = dependencySnapshot(
    collectDependencyInputs(packageRoot, options, traversalLimits),
  );
  if (!isDeepStrictEqual(dependencySnapshotBefore, dependencySnapshotAfter)) {
    throw new Error(
      `Analyzer dependency runtime changed while its identity was being computed: ${packageRoot}`,
    );
  }

  const nextCache: IdentityCachePayload = {

View on GitHub (pinned to d540b00184)

Solutions

  1. Add a string version to the root package.json: `"version": "0.0.0"` (private packages may use any semver-ish string).
  2. Validate before running: `node -e "const p=require('./package.json'); if(typeof p.version!=='string'||!p.version.trim())throw 1"`.
  3. If the root is genuinely versionless by convention, give it a placeholder version and document it.
  4. Ensure your build templating never emits a non-string or empty version.

Example fix

// before: package.json
//   { "name": "my-repo", "private": true }
//   -> "GitNexus package version is unavailable in /repo"
//
// after:
//   { "name": "my-repo", "private": true, "version": "0.0.0" }
Defensive patterns

Strategy: validation

Validate before calling

function assertRootPackageVersion(packageRoot) {
  const fs = require('node:fs');
  const path = require('node:path');
  const manifest = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
  if (typeof manifest.version !== 'string' || manifest.version.trim() === '') {
    throw new Error(`Root package.json must have a non-empty string "version"; got ${JSON.stringify(manifest.version)}`);
  }
}
// assertRootPackageVersion(process.cwd());

Type guard

function hasStringVersion(manifest) {
  return typeof manifest?.version === 'string' && manifest.version.trim().length > 0;
}

Prevention

When it happens

Trigger: resolveAnalyzerRunnerIdentity reads dependencyInputs.packages[0].manifest.version; if `typeof version !== 'string'` or `version.trim() === ''`, the throw fires naming packageRoot. Triggered by a root package.json missing the `version` field, with `"version": ""`, or with `"version": null` / a numeric literal.

Common situations: A private workspace root whose package.json omits `version` (some monorepo templates do this for the aggregate root); a package.json hand-edited and the version line deleted; a JSON5/JSON-with-comments file where a tool stripped the field; a CI build that templates package.json and left version blank; `"version": 1.2.3` (numeric, not string).

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/62787b2f99ca582d. Report an issue: GitHub.