{"record":{"id":"30ea66e87b1cf2a5","repo":"quarkusio/quarkus","slug":"failed-to-create-jbang-install-directory-dir","errorCode":null,"errorMessage":"Failed to create JBang install directory: ${dir}","messagePattern":"Failed to create JBang install directory: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangSupport.java","lineNumber":194,"sourceCode":"            dir = dir.map(Path::getParent);\n        }\n        return dir.map(d -> d.resolve(\".jbang\"))\n                .orElseThrow(() -> new IllegalStateException(\"Failed to determine .jbang directory\"));\n    }\n\n    private void installJBang() {\n        try {\n            String uri = \"https://www.jbang.dev/releases/latest/download/jbang.zip\";\n            Path downloadDir = Files.createTempDirectory(\"jbang-download-\");\n\n            if (!downloadDir.toFile().exists() && !downloadDir.toFile().mkdirs()) {\n                throw new IOException(\"Failed to create JBang download directory: \" + downloadDir.toAbsolutePath().toString());\n            }\n\n            Path downloadFile = downloadDir.resolve(\"jbang.zip\");\n            Path installDir = getInstallationDir();\n            if (!installDir.toFile().exists() && !installDir.toFile().mkdirs()) {\n                throw new IOException(\"Failed to create JBang install directory: \" + installDir.toAbsolutePath().toString());\n            }\n            HttpClient client = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.ALWAYS).build();\n            HttpRequest request = HttpRequest.newBuilder()\n                    .uri(new URI(uri))\n                    .GET()\n                    .build();\n            HttpResponse<Path> response = client.send(request, BodyHandlers.ofFile(downloadFile));\n            ZipUtils.unzip(downloadFile, downloadDir);\n            ZipUtils.copyFromZip(downloadDir.resolve(\"jbang\"), installDir);\n        } catch (Exception e) {\n            throw new RuntimeException(e);\n        }\n    }\n}\n","sourceCodeStart":176,"sourceCodeEnd":209,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/cli/plugin/JBangSupport.java#L176-L209","documentation":"JBangSupport.installJBang throws IOException 'Failed to create JBang install directory: <absolute path>' when the JBang installation directory (from getInstallationDir()) neither exists nor can be created via mkdirs(). This blocks downloading/unzipping JBang into place. The exception propagates as a wrapped RuntimeException to the caller of doEnsureJBangIsInstalledInternal.","triggerScenarios":"Calling ensureJBangIsInstalled when the installation directory path cannot be created — parent path is a file, permissions deny mkdirs, or the filesystem is read-only.","commonSituations":"Read-only QUARKUS_USER_HOME or ~/.quarkus; a regular file exists at the installation dir path; enterprise-managed machines restricting writes to home; disk full.","solutions":["Check permissions on the parent of the installation directory and create it manually: mkdir -p <installDir>","Ensure no regular file occupies the installation directory path (remove/rename it)","Override the JBang installation location to a writable path via the supported config/env and retry"],"exampleFix":"// before\nls -la ~/.quarkus  // jbang exists as a FILE\n\n// after\nmv ~/.quarkus/jbang ~/.quarkus/jbang.bak && mkdir -p ~/.quarkus/jbang","handlingStrategy":"validation","validationCode":"Path installDir = Paths.get(System.getProperty(\"user.home\"), \".quarkus\", \"jbang\");\nFile f = installDir.toFile();\nif (f.exists() && !f.isDirectory())\n    throw new IllegalStateException(\"Install path occupied by a file: \" + installDir);\nif (!f.exists() && !f.getParentFile().canWrite())\n    throw new IllegalStateException(\"Cannot create install dir: \" + installDir);","typeGuard":null,"tryCatchPattern":"try {\n    jbangSupport.ensureJBangIsInstalled();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Failed to create JBang install directory\")) {\n        // mkdir -p the dir or remove the blocking file, then retry\n    } else throw e;\n}","preventionTips":["Ensure ~/.quarkus (or your configured QUARKUS_USER_HOME) is a writable directory","Check that the install path is not shadowed by a regular file","On locked-down machines, install JBang manually via SDKMAN/jbang.dev instead of letting the CLI install it"],"tags":["filesystem","jbang","permissions"],"backgroundTag":"file-create-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}