quarkusio/quarkus · error · RuntimeException

Should never reach this!

Error message

Should never reach this!

What it means

During quarkus:run, QuarkusRun.accept matches runnable commands contributed by installed extensions. If none matched (cmds.size()==0) and fewer than 3 commands exist in an unexpected state, it throws RuntimeException("Should never reach this!") — a defensive assertion for an internal invariant that normally cannot occur.

Source

Thrown at devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java:148

                        cmd = cmds.get(target);
                        if (cmd == null) {
                            exists.set(false);
                            return;
                        }
                    } else if (cmds.size() == 1) { // defaults to pure java run
                        cmd = cmds.values().iterator().next();
                    } else if (cmds.size() == 2) { // choose not default
                        for (Map.Entry<String, List> entry : cmds.entrySet()) {
                            if (entry.getKey().equals("java"))
                                continue;
                            cmd = entry.getValue();
                            break;
                        }
                    } else if (cmds.size() > 2) {
                        tooMany.set(cmds.keySet().stream().collect(Collectors.joining(" ")));
                        return;
                    } else {
                        throw new RuntimeException("Should never reach this!");
                    }
                    List<String> args = (List<String>) cmd.get(0);
                    if (getJvmArguments().isPresent() && !getJvmArguments().get().isEmpty()) {
                        args.addAll(1, getJvmArgs());
                    }

                    getLogger().info("Executing \"" + String.join(" ", args) + "\"");
                    Path wd = (Path) cmd.get(1);
                    File wdir = wd != null ? wd.toFile() : workingDirectory.get();

                    // this was all very touchy to get the process outputing to console and exiting cleanly
                    // change at your own risk

                    // We cannot use getProject().exec() as contrl-c is not processed correctly
                    // and the spawned process will not shutdown
                    //
                    // This also requires running with --no-daemon as control-c doesn't seem to trigger the shutdown hook
                    // this poor gradle behavior is a long known issue with gradle

View on GitHub (pinned to e1c734241f)

Solutions

  1. Set -Dquarkus.run.target=<target> explicitly to bypass command auto-detection.
  2. Check installed extensions supporting quarkus:run (the 'too many' message lists them) and remove conflicting ones.
  3. If reproducible, report a Quarkus bug with the extension list and build.gradle — this indicates an unexpected internal state.

Example fix

// before
./gradlew quarkusRun

// after (explicit target avoids detection logic)
./gradlew quarkusRun -Dquarkus.run.target=io.quarkus.example.Main
Defensive patterns

Strategy: fallback

Validate before calling

// always specify the run target to avoid auto-detection edge cases
./gradlew quarkusRun -Dquarkus.run.target=com.example.Main

Try / catch

try { runQuarkus() } catch (RuntimeException e) { if (e.message == 'Should never reach this!') { /* rerun with -Dquarkus.run.target=... ; otherwise report bug */ } }

Prevention

When it happens

Trigger: The command-matching loop completes with no matching command and cmds is empty or size 1 — effectively only when extension-provided run commands are missing or an unexpected internal state occurs; also reachable as a guard alongside the 'too many commands' path.

Common situations: Bugs/edge cases in extension-contributed run commands; unusual combinations of installed extensions providing quarkus:run commands; typically a library bug rather than user error.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/17b476853d532bb0. Report an issue: GitHub.