{"record":{"id":"6b76685e2497bf94","repo":"elastic/elasticsearch","slug":"gradle-is-running-in-offline-mode-but-branches-js","errorCode":null,"errorMessage":"Gradle is running in offline mode, but branches.json location [{configuredBranchesFileLocation}] is an http(s) URL and no local branches.json was found at [{localBranchesFile}]. Either disable offline mode, set -P{BRANCHES_FILE_LOCATION_PROPERTY}=<local file path>, or create branches.json at the workspace root.","messagePattern":"Gradle is running in offline mode, but branches\\.json location \\[(.+?)\\] is an http\\(s\\) URL and no local branches\\.json was found at \\[(.+?)\\]\\. Either disable offline mode, set -P(.+?)=<local file path>, or create branches\\.json at the workspace root\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java","lineNumber":231,"sourceCode":"            .toList();\n    }\n\n    private List<DevelopmentBranch> getDevelopmentBranches() {\n        String configuredBranchesFileLocation = project.getProviders()\n            .gradleProperty(BRANCHES_FILE_LOCATION_PROPERTY)\n            .getOrElse(DEFAULT_BRANCHES_FILE_URL);\n        String branchesFileLocation = configuredBranchesFileLocation;\n        if (project.getGradle().getStartParameter().isOffline() && isHttpLocation(configuredBranchesFileLocation)) {\n            File localBranchesFile = new File(Util.locateElasticsearchWorkspace(project.getGradle()), \"branches.json\");\n            if (localBranchesFile.exists()) {\n                LOGGER.warn(\n                    \"Gradle is running in offline mode; using local branches.json at [{}] instead of downloading from [{}].\",\n                    localBranchesFile,\n                    configuredBranchesFileLocation\n                );\n                branchesFileLocation = localBranchesFile.getAbsolutePath();\n            } else {\n                throw new GradleException(\n                    \"Gradle is running in offline mode, but branches.json location [\"\n                        + configuredBranchesFileLocation\n                        + \"] is an http(s) URL and no local branches.json was found at [\"\n                        + localBranchesFile\n                        + \"]. Either disable offline mode, set -P\"\n                        + BRANCHES_FILE_LOCATION_PROPERTY\n                        + \"=<local file path>, or create branches.json at the workspace root.\"\n                );\n            }\n        }\n        LOGGER.info(\"Reading branches.json from {}\", branchesFileLocation);\n        byte[] branchesBytes;\n        if (isHttpLocation(branchesFileLocation)) {\n            try {\n                branchesBytes = HttpUtils.readHttpBytesWithRetry(branchesFileLocation);\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"Failed to download branches.json from: \" + branchesFileLocation, e);\n            }","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java#L213-L249","documentation":"Thrown by GlobalBuildInfoPlugin.getDevelopmentBranches() when Gradle is in offline mode (--offline), the branches.json location is an http(s) URL (the default DEFAULT_BRANCHES_FILE_URL or a user-configured URL via the branches.file.location Gradle property), and no local branches.json file exists at the workspace root. This is a hard failure because the build cannot proceed without branch information in offline mode.","triggerScenarios":"Gradle is started with --offline flag. The branches.file.location Gradle property is not set or is set to an http(s) URL. No branches.json file exists at Util.locateElasticsearchWorkspace(gradle)/branches.json. All three conditions must be true simultaneously.","commonSituations":"A developer runs ./gradlew build --offline on a plane or behind a firewall. CI agents in an air-gapped environment use --offline but branches.json was never placed at the workspace root. The default URL changed and no local copy was cached.","solutions":["Place a branches.json file at the root of the Elasticsearch workspace.","Pass a local file path: ./gradlew build --offline -Pbranches.file.location=/path/to/local/branches.json.","Remove the --offline flag if network access is available.","Download branches.json from the default URL once and commit or cache it at the workspace root for offline use."],"exampleFix":"# before\n./gradlew build --offline  # no branches.json at workspace root\n\n# after (option 1: local file)\ncurl -o branches.json https://.../branches.json\n./gradlew build --offline\n\n# after (option 2: explicit local path)\n./gradlew build --offline -Pbranches.file.location=/home/user/branches.json","handlingStrategy":"fallback","validationCode":"// Check offline mode and branches.json before building\nboolean offline = gradle.getStartParameter().isOffline();\nFile localBranches = new File(workspaceDir, \"branches.json\");\nif (offline && !localBranches.exists()) {\n    throw new GradleException(\"Offline mode requires branches.json at workspace root or -Pbranches.file.location=<local path>\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Place a branches.json at the workspace root for offline builds.","Use -Pbranches.file.location=<local path> to point to a local copy.","Only use --offline when you have all required local files cached."],"tags":["gradle","offline","branches","network","configuration"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}