apache/maven · error · IOException

Unable to prompt

Error message

Unable to prompt

What it means

LegacyPlexusInteractivity.readLine() bridges legacy components to the new Prompter SPI by calling prompter.prompt(null); any PrompterException is converted into IOException('Unable to prompt'). It fires when a prompt cannot be delivered at all: no console attached, stdin at EOF, or the prompter implementation itself failing - not when the user types a wrong answer.

Source

Thrown at compat/maven-compat/src/main/java/org/apache/maven/internal/compat/interactivity/LegacyPlexusInteractivity.java:57

 */
@Experimental
@Named
@Singleton
@Priority(10)
public class LegacyPlexusInteractivity implements Prompter, InputHandler, OutputHandler {
    private final org.apache.maven.api.services.Prompter prompter;

    @Inject
    public LegacyPlexusInteractivity(org.apache.maven.api.services.Prompter prompter) {
        this.prompter = prompter;
    }

    @Override
    public String readLine() throws IOException {
        try {
            return prompter.prompt(null);
        } catch (org.apache.maven.api.services.PrompterException e) {
            throw new IOException("Unable to prompt", e);
        }
    }

    @Override
    public String readPassword() throws IOException {
        try {
            return prompter.promptForPassword(null);
        } catch (org.apache.maven.api.services.PrompterException e) {
            throw new IOException("Unable to prompt", e);
        }
    }

    @Override
    public List<String> readMultipleLines() throws IOException {
        List<String> lines = new ArrayList<>();
        for (String line = readLine(); line != null && !line.isEmpty(); line = readLine()) {
            lines.add(line);
        }

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Run the build in a real terminal when the tool genuinely needs interactive input
  2. Replace the prompt with configuration: pass values via settings.xml, -D properties, or environment variables (e.g. gpg.passphrase)
  3. Run mvn -B/--batch-mode with credentials fully preconfigured so nothing ever prompts
  4. If stdin must be piped, ensure it provides the expected line: printf 'answer\n' | mvn ...

Example fix

# before: CI hangs/prompts and dies on EOF
mvn release:prepare
# after: batch mode with preconfigured values
mvn -B -Dgpg.passphrase=${env.GPG_PASSPHRASE} release:prepare
Defensive patterns

Strategy: try-catch

Validate before calling

if (System.console() == null) {
    // no interactive console: do not call readLine(); use config/env instead
}

Try / catch

Catch IOException from readLine(); when the message is 'Unable to prompt', switch to a non-interactive source (property, environment variable, settings.xml) rather than retrying the prompt.

Prevention

When it happens

Trigger: A legacy maven-compat component calling readLine() where System.console() is null (piped stdin, CI service, daemon), after stdin reaches EOF, or where no usable Prompter implementation is registered in the container.

Common situations: CI running an old plugin that asks for input (GPG passphrase, SCM login) with stdin closed; Maven run as a service; piping input like `echo | mvn ...` where EOF arrives before the prompt is answered.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/0d2e0884a968feea. Report an issue: GitHub.