{"record":{"id":"166368ad9db5a2a7","repo":"xpipe-io/xpipe","slug":"unable-to-set-up-scripts","errorCode":null,"errorMessage":"Unable to set up scripts","messagePattern":"Unable to set up scripts","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStoreSetup.java","lineNumber":109,"sourceCode":"                                }\n\n                                return Optional.ofNullable(shellControl\n                                        .getShellDialect()\n                                        .addToPathVariableCommand(List.of(dir.toString()), true));\n                            }\n\n                            @Override\n                            public boolean canPotentiallyRunInDialect(ShellDialect dialect) {\n                                return true;\n                            }\n                        },\n                        append);\n            }\n        } catch (StackOverflowError t) {\n            throw ErrorEventFactory.expected(\n                    new RuntimeException(\"Unable to set up scripts. Is there a circular script dependency?\", t));\n        } catch (Throwable t) {\n            throw new RuntimeException(\"Unable to set up scripts\", t);\n        }\n    }\n\n    @SneakyThrows\n    private static FilePath initScriptsDirectory(ShellControl sc, List<DataStoreEntryRef<ScriptStore>> refs) {\n        if (refs.isEmpty()) {\n            return null;\n        }\n\n        var applicable =\n                refs.stream().filter(ss -> ss.getStore().isCompatible(sc)).toList();\n        if (applicable.isEmpty()) {\n            return null;\n        }\n\n        var hash = refs.stream()\n                .mapToInt(value ->\n                        value.get().getName().hashCode() + value.getStore().hashCode())","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/xpipe-io/xpipe/blob/d85ca821baa46092a320ebb13546d7240adb74f8/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptStoreSetup.java#L91-L127","documentation":"ScriptStoreSetup.controlWithScripts() wraps script initialization (initScriptsDirectory and applying each script ref) and rethrows any Throwable as RuntimeException(\"Unable to set up scripts\", t). A StackOverflowError is specially converted to an 'expected' error hinting at circular script dependencies. This error means the shell setup phase could not install/apply the configured scripts.","triggerScenarios":"Calling controlWithScripts/controlWithDefaultScripts for a connection whose script references fail: initScriptsDirectory throws (shell/directory problems), a script's apply step throws, or a StackOverflowError occurs from a script depending on itself (circular ScriptStore reference chain).","commonSituations":"Circular script dependency (script A references script B which references A) causing StackOverflowError; a referenced script store is broken or empty; shell connection fails while creating the scripts directory; permission problems creating init scripts on the remote machine.","solutions":["Inspect the cause (getCause()) to find the real failure; for StackOverflowError, look for circular script dependencies and remove the self/cross reference","Validate each referenced ScriptStore with checkComplete() before connecting","Verify the shell connection and permissions for creating the scripts directory on the target machine","Temporarily remove script references from the connection to isolate the failing script"],"exampleFix":"// before (circular)\nscriptA.getScripts().add(refOf(scriptA));\n// after\n// reference a different script, or remove the self-reference\nscriptA.getScripts().remove(refOf(scriptA));","handlingStrategy":"try-catch","validationCode":"// before connecting\nfor (var ref : scriptRefs) {\n    ref.getStore().checkComplete(); // fail fast on broken scripts\n}","typeGuard":null,"tryCatchPattern":"try {\n    controlWithDefaultScripts(sc);\n} catch (RuntimeException e) {\n    Throwable c = e.getCause();\n    if (c instanceof StackOverflowError) {\n        // circular script dependency: inspect script reference graph\n    }\n}","preventionTips":["Model script dependencies as a DAG — never reference a script from itself","Run checkComplete() on referenced script stores before connecting","Test shell setup on a copy of the connection without scripts"],"tags":["shell-setup","scripts","circular-dependency","connection"],"backgroundTag":"invalid-config-value","analyzedSha":"d85ca821baa46092a320ebb13546d7240adb74f8","analyzedAt":"2026-09-06T14:30:08.251Z","contentChangedAt":"2026-09-06T14:30:08.251Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}