{"record":{"id":"0010f2ec473e8cd9","repo":"xpipe-io/xpipe","slug":"local-shell-not-initialized-yet","errorCode":null,"errorMessage":"Local shell not initialized yet","messagePattern":"Local shell not initialized yet","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/xpipe/app/process/LocalShell.java","lineNumber":122,"sourceCode":"            localPowershell = ProcModuleProvider.get()\n                    .createLocalProcessControl(false)\n                    .subShell(ShellDialects.POWERSHELL)\n                    .start();\n            localPowershell.getShellDialect().getDumbMode().throwIfUnsupported();\n        } catch (Exception ex) {\n            localPowershell = null;\n            ErrorEventFactory.fromThrowable(ex)\n                    .description(\"Failed to start local powershell process\")\n                    .handle();\n        }\n\n        return Optional.ofNullable(localPowershell);\n    }\n\n    @SneakyThrows\n    public static ShellControl getShell() {\n        if (local == null) {\n            throw new IllegalStateException(\"Local shell not initialized yet\");\n        }\n\n        return local.start();\n    }\n\n    public static ShellDialect getDialect() {\n        return ProcModuleProvider.get().getEffectiveLocalDialect();\n    }\n}\n","sourceCodeStart":104,"sourceCodeEnd":132,"githubUrl":"https://github.com/xpipe-io/xpipe/blob/d85ca821baa46092a320ebb13546d7240adb74f8/app/src/main/java/io/xpipe/app/process/LocalShell.java#L104-L132","documentation":"LocalShell.getShell() returns the cached, lazily-initialized local shell connection. If LocalShell.init() has not yet run (static field local == null), there is no shell to hand out and an IllegalStateException is thrown. This is an initialization-order guard, not a shell failure.","triggerScenarios":"Any code path calling LocalShell.getShell() before LocalShell.init() completed, or after initialization failed silently leaving local null.","commonSituations":"Calling store/query APIs very early during app startup before the local shell bootstrap; unit tests instantiating classes that depend on LocalShell without initializing it; initialization failure swallowed earlier in startup.","solutions":["Ensure LocalShell.init() runs before any code that resolves local-machine stores","In tests, call the init/test hook to bootstrap a local shell in setup","Check startup logs for an earlier exception that prevented shell initialization"],"exampleFix":"// before\nvar shell = LocalShell.getShell();\n// after\nLocalShell.init(); // in setup/bootstrap, before first use\nvar shell = LocalShell.getShell();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"boolean localShellReady() { try { var f = LocalShell.class.getDeclaredField(\"local\"); f.setAccessible(true); return f.get(null) != null; } catch (Exception e) { return false; } }","tryCatchPattern":"try { var shell = LocalShell.getShell(); ... } catch (IllegalStateException e) { if (e.getMessage().equals(\"Local shell not initialized yet\")) { LocalShell.init(); shell = LocalShell.getShell(); } else throw e; }","preventionTips":["Initialize LocalShell in app bootstrap before any store access","In tests, bootstrap the shell in @SetUp","Don't swallow exceptions during shell init"],"tags":["initialization","shell","lifecycle"],"backgroundTag":"invalid-state-transition","analyzedSha":"d85ca821baa46092a320ebb13546d7240adb74f8","analyzedAt":"2026-09-06T14:30:08.251Z","contentChangedAt":"2026-09-06T14:30:08.251Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}