{"record":{"id":"06c661a1d6d4aa77","repo":"arduino/Arduino","slug":"board-is-not-selected","errorCode":null,"errorMessage":"Board is not selected","messagePattern":"Board is not selected","errorType":"exception","errorClass":"RunnerException","httpStatus":null,"severity":"error","filePath":"arduino-core/src/cc/arduino/Compiler.java","lineNumber":168,"sourceCode":"  public Compiler(File pathToSketch, Sketch sketch) {\n    this.pathToSketch = pathToSketch;\n    this.sketch = sketch;\n    this.verbose = PreferencesData.getBoolean(\"build.verbose\");\n  }\n\n  public String build(CompilerProgressListener progListener, boolean exportHex) throws RunnerException, PreferencesMapException, IOException {\n    List<CompilerProgressListener> listeners = new ArrayList<>();\n    listeners.add(progListener);\n    return this.build(listeners, exportHex);\n  }\n\n  public String build(List<CompilerProgressListener> progListeners, boolean exportHex) throws RunnerException, PreferencesMapException, IOException {\n    this.buildPath = sketch.getBuildPath().getAbsolutePath();\n    this.buildCache = BaseNoGui.getCachePath();\n\n    TargetBoard board = BaseNoGui.getTargetBoard();\n    if (board == null) {\n      throw new RunnerException(\"Board is not selected\");\n    }\n\n    TargetPlatform platform = board.getContainerPlatform();\n    TargetPackage aPackage = platform.getContainerPackage();\n    String vidpid = VIDPID();\n\n    PreferencesMap prefs = loadPreferences(board, platform, aPackage, vidpid);\n\n    MessageConsumerOutputStream out = new MessageConsumerOutputStream(new ProgressAwareMessageConsumer(new I18NAwareMessageConsumer(System.out, System.err), progListeners), \"\\n\");\n    MessageConsumerOutputStream err = new MessageConsumerOutputStream(new I18NAwareMessageConsumer(System.err, Compiler.this), \"\\n\");\n\n    callArduinoBuilder(board, platform, aPackage, vidpid, BuilderAction.COMPILE, out, err);\n\n    out.flush();\n    err.flush();\n\n    if (exportHex) {\n      runActions(\"hooks.savehex.presavehex\", prefs);","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/cc/arduino/Compiler.java#L150-L186","documentation":"Compiler.build() requires a target board to be selected before compiling a sketch. It calls BaseNoGui.getTargetBoard() and if no board is set (null), it aborts with a RunnerException because board-specific parameters (platform, package, vid/pid, build path) cannot be resolved. This is a precondition failure of the build pipeline, not a compilation error in the sketch itself.","triggerScenarios":"Calling Compiler.build() (directly or via BaseNoGui/IDE build flow) while no board has been selected, i.e. BaseNoGui.getTargetBoard() returns null because Preferences 'board' key is unset or references a non-existent board id.","commonSituations":"Headless/CLI builds (arduino-builder style usage) where the user forgot to set the board; preferences.txt corrupted or reset so the stored board id no longer maps to an installed package; a board package was uninstalled while it was still the selected board.","solutions":["Select a board before building: BaseNoGui.setTargetBoard()/select the board in Tools > Board, ensuring the matching platform/package is installed.","Verify the 'board' (and 'target_package'/'target_platform') preferences point to an installed board package.","Reinstall the board core package if the selected board id no longer exists in any installed index.","Wrap build() in error handling and surface a 'select a board' message to the end user instead of a stack trace."],"exampleFix":"// before\nnew Compiler(sketch).build(progListeners, exportHex);\n// after\nif (BaseNoGui.getTargetBoard() == null) {\n  BaseNoGui.setTargetBoard(\"arduino:avr:uno\"); // or prompt the user\n}\nnew Compiler(sketch).build(progListeners, exportHex);","handlingStrategy":"validation","validationCode":"if (BaseNoGui.getTargetBoard() == null) { throw new IllegalStateException(\"Select a board before building\"); }","typeGuard":null,"tryCatchPattern":"try { compiler.build(listeners, exportHex); } catch (RunnerException e) { if (\"Board is not selected\".equals(e.getMessage())) { promptBoardSelection(); } else { throw e; } }","preventionTips":["Always configure the board (BaseNoGui.setTargetBoard or preferences) before invoking build.","In headless pipelines, assert board preferences are present at startup.","Re-validate board selection after installing/removing board packages."],"tags":["arduino","build","missing-selection","configuration"],"backgroundTag":"missing-required-config","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}