cube-js/cube · error
Unable to resolve maven dependencies, mvn exited with: "${mv
Error message
Unable to resolve maven dependencies, mvn exited with: "${mvnOutput.status}" code What it means
@cubejs-backend-maven shells out to the `mvn` CLI to resolve Java dependencies (e.g. for JDBC drivers). If the maven process exits with a non-zero status, dependency resolution failed and the library surfaces mvn's exit code. It indicates mvn itself ran but could not resolve/download the dependencies.
Source
Thrown at packages/cubejs-backend-maven/src/maven.ts:150
}
}
return getExternalMaven();
}
async function installDependencies(pathToPom: string, options: ResolveOptions) {
const { binary } = await getMaven(options);
// https://search.maven.org/artifact/de.qaware.maven/go-offline-maven-plugin/1.2.8/jar
const mvnOutput = spawnSync(binary, ['de.qaware.maven:go-offline-maven-plugin:1.2.8:resolve-dependencies', '-f', pathToPom], {
stdio: options.showOutput ? 'inherit' : 'pipe',
encoding: 'utf8'
});
if (mvnOutput.status === 0) {
return;
}
throw new Error(
`Unable to resolve maven dependencies, mvn exited with: "${mvnOutput.status}" code`
);
}
export async function resolveDependencies(dependecies: MavenDependency[], options: ResolveOptions) {
const pathToPom = path.resolve(os.tmpdir(), 'cubejs-pom.xml');
fs.writeFileSync(pathToPom, generateXml(dependecies));
await installDependencies(pathToPom, options);
}
export function getDependenciesFromPackage(): MavenDependency[] {
const pathToLock = path.join(process.cwd(), 'package.json');
if (!fs.existsSync(pathToLock)) {
throw new Error(
`Unable to find package.json file in current working directory: ${process.cwd()}`View on GitHub (pinned to 7d981676b3)
Solutions
- Run `mvn` manually with the same goal (check the generated cubejs-pom.xml in os.tmpdir()) to see the real error output.
- Ensure network/proxy access to Maven Central (or configure mirrors in ~/.m2/settings.xml).
- Verify the maven dependency coordinates (groupId/artifactId/version) passed to resolveDependencies are valid.
- Confirm `mvn -v` works and a compatible JDK is installed.
Example fix
// before
await resolveDependencies([{ artifactId: 'mysql-connector', version: '99' }], options);
// after
await resolveDependencies([{ groupId: 'com.mysql', artifactId: 'mysql-connector-j', version: '8.0.33' }], options); Defensive patterns
Strategy: try-catch
Validate before calling
const { execFileSync } = require('child_process');
try {
execFileSync('mvn', ['-v'], { stdio: 'ignore' });
} catch {
throw new Error('mvn must be installed and on PATH before resolving maven dependencies');
} Try / catch
try {
await resolveDependencies(deps, options);
} catch (e) {
if (/Unable to resolve maven dependencies/.test(e.message)) {
console.error('mvn failed; run the maven goal manually for full logs and check proxy/credentials.');
} else throw e;
} Prevention
- Verify mvn and a JDK are installed and on PATH before starting the Cube server.
- Test network access to Maven Central (or configure settings.xml mirrors/proxy).
- Pin valid dependency coordinates and versions in your driver config.
When it happens
Trigger: Calling installDependencies (via resolveDependencies) when the spawned `mvn dependency:...` command exits with any status other than 0 — e.g. missing dependencies, bad pom, no network to Maven Central.
Common situations: Offline/behind-proxy environments where Maven Central is unreachable; corrupted or partial ~/.m2 cache; invalid version coordinates in the maven dependencies list; mvn installed but misconfigured (settings.xml issues); Java/JDK not on PATH causing mvn to fail.
Related errors
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/e753af1e083e5d0e.
Report an issue: GitHub.