abhigyanpatwari/GitNexus · error

GitNexus package version is unavailable in

Error message

GitNexus package version is unavailable in ${packageRoot}

What it means

The analyzer runner identity embeds the GitNexus package version read from the first dependency package's package.json manifest (dependencyInputs.packages[0].manifest.version). If that field is missing or blank (after trim), identity computation refuses to proceed because a versionless identity cannot be compared or cached safely.

Solutions

  1. Install a real published release: npm install -g gitnexus@latest (the npm tarball always carries a version).
  2. If running from a git checkout, build and pack first (npm pack in gitnexus/) and install the resulting tarball.
  3. Restore the version field in <packageRoot>/package.json if you maintain a fork.
  4. Verify with node -p "require('<packageRoot>/package.json').version" that it prints a non-empty string.

Example fix

# before
npm install -g github:yourorg/gitnexus   # manifest rewritten, version lost
npx gitnexus analyze
# GitNexus package version is unavailable in /usr/lib/node_modules/gitnexus

# after: install a published release
cd gitnexus && npm pack && npm install -g gitnexus-<version>.tgz
npx gitnexus analyze
Defensive patterns

Strategy: validation

Validate before calling

// Before running the CLI against an install, verify the manifest version:
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
function packageVersionPresent(packageRoot: string): boolean {
  try {
    const v = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8')).version;
    return typeof v === 'string' && v.trim() !== '';
  } catch {
    return false;
  }
}

Try / catch

try {
  spawnSync('gitnexus', ['analyze']);
} catch (err) {
  if (String((err as Error).message).includes('GitNexus package version is unavailable')) {
    await reinstallPublishedRelease(); // npm install -g gitnexus@latest
    return spawnSync('gitnexus', ['analyze']);
  }
  throw err;
}

Prevention

When it happens

Trigger: resolveAnalyzerRunnerIdentity() where the root package.json of the resolved analyzer install lacks a version field, has version: '' or a whitespace-only value — typically a hand-copied or patched install, a git checkout consumed without the build/pack step, or a corrupted publish.

Common situations: Installing from a git URL (npm i github:org/gitnexus) where tooling rewrote package.json, Docker images that strip manifest metadata, internal forks that hand-edit the manifest, or file: installs of a partial package.

Related errors


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

Appendix: source

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

        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 52924ef12c)