oracle/graal · critical · ValueError

nargs not allowed

Error message

nargs not allowed

What it means

DefaultHomeFinder falls back to the java.home system property to locate the GraalVM installation when no explicit GraalVM home was configured. If System.getProperty("java.home") returns null it throws an AssertionError, because the finder assumes a JVM always defines java.home. In practice this only happens on a broken, stripped-down, or manually constructed runtime.

Source

Thrown at compiler/mx.compiler/mx_compiler.py:800

    BootstrapTest('BootstrapWithSystemAssertionsEconomy', _bootstrapFlags + _defaultFlags + _assertionFlags + _graalEconomyFlags + _graalErrorFlags, tags=GraalTags.bootstrapeconomy),
    BootstrapTest('BootstrapWithSystemAssertionsExceptionEdges', _bootstrapFlags + _defaultFlags + _assertionFlags + _exceptionFlags + _graalErrorFlags, tags=GraalTags.bootstrap),
    BootstrapTest('BootstrapWithSystemAssertionsRegisterPressure', _bootstrapFlags + _defaultFlags + _assertionFlags + _registerPressureFlags + _graalErrorFlags, tags=GraalTags.bootstrap),
]

_runs_on_github_actions = 'GITHUB_ACTION' in os.environ

def _graal_gate_runner(args, tasks):
    compiler_gate_runner(['compiler', 'truffle'], graal_unit_test_runs, graal_bootstrap_tests, tasks, args.extra_vm_argument, args.extra_unittest_argument)
    if not _runs_on_github_actions:
        compiler_gate_benchmark_runner(tasks, args.extra_vm_argument, task_report_component='compiler')

class ShellEscapedStringAction(argparse.Action):
    """Turns a shell-escaped string into a list of arguments.
       Note that it appends the result to the destination.
    """
    def __init__(self, option_strings, nargs=None, **kwargs):
        if nargs is not None:
            raise ValueError("nargs not allowed")
        super().__init__(option_strings, **kwargs)

    def __call__(self, parser, namespace, values, option_string=None):
        # do not override existing values
        old_values = getattr(namespace, self.dest)
        # shlex.split interprets '\' as an escape char so it needs to be escaped itself
        values = values.replace("\\", "\\\\")
        setattr(namespace, self.dest, (old_values if old_values else []) + shlex.split(values))

mx_gate.add_gate_runner(_suite, _graal_gate_runner)
mx_gate.add_gate_argument('--extra-vm-argument', action=ShellEscapedStringAction, help='add extra vm arguments to gate tasks if applicable')
mx_gate.add_gate_argument('--extra-unittest-argument', action=ShellEscapedStringAction, help='add extra unit test arguments to gate tasks if applicable')

def _unittest_vm_launcher(vmArgs, mainClass, mainClassArgs):
    if jdk.tag == 'graalvm':
        # we do not want to use -server for GraalVM configurations
        mx.run_java(vmArgs + [mainClass] + mainClassArgs, jdk=jdk)
    else:

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Do not remove or blank the java.home system property; restore it if a test scrubbed it.
  2. Set an explicit GraalVM home (graalvm.home system property / GRAALVM_HOME env var honored by DefaultHomeFinder) so the java.home fallback path is never taken.
  3. If you control the launcher, ensure it initializes standard system properties like java.home.

Example fix

// before
System.getProperties().remove("java.home");
Version v = Version.getCurrent();

// after
// keep java.home intact, or pin the lookup explicitly:
System.setProperty("graalvm.home", "/opt/graalvm");
Version v = Version.getCurrent();
Defensive patterns

Strategy: validation

Validate before calling

if (System.getProperty("java.home") == null) {
    throw new IllegalStateException("java.home is unset; cannot locate GraalVM home");
}
Version.getCurrent();

Prevention

When it happens

Trigger: Running on a JVM launched with java.home removed (e.g. -Djava.home cleared via reflection or a custom launcher), inside minimal/custom runtimes where java.home is undefined, or in tests that sanitize system properties and then trigger home lookup (Version.getCurrent(), HomeFinder.findHome()).

Common situations: Over-aggressive system-property scrubbing in test harnesses; embedding the SDK in a non-standard launcher; security managers or instrumentation that hide system properties.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/4312b459301a747e. Report an issue: GitHub.