{"record":{"id":"711fb6b33be14e97","repo":"dagger/dagger","slug":"download-error-failed-to-use-cli-from-path-cli","errorCode":null,"errorMessage":"{download_error}\nfailed to use CLI from PATH {cli_bin!r}: {e}","messagePattern":"(.+?)\nfailed to use CLI from PATH (.+?): (.+?)","errorType":"exception","errorClass":"ExceptionGroup","httpStatus":null,"severity":"critical","filePath":"sdk/python/src/dagger/provisioning/_engine.py","lineNumber":111,"sourceCode":"            download_error = None\n            try:\n                cli_bin = await self.get_cli()\n            except CLIReleaseUnavailableError as e:\n                download_error = e\n                cli_bin = fallback_to_local_cli(e, self.cfg.log_output)\n\n            await self.progress.update(\"Creating new Engine session\")\n            try:\n                connect_params = await self.stack.enter_async_context(\n                    start_cli_session(self.cfg, cli_bin)\n                )\n            except Exception as e:\n                if download_error is not None:\n                    msg = (\n                        f\"{download_error}\\nfailed to use CLI from PATH \"\n                        f\"{cli_bin!r}: {e}\"\n                    )\n                    raise ExceptionGroup(msg, [download_error, e]) from e\n                raise\n\n        self.connect_params = connect_params\n        self.connect_config = ConnectConfig(\n            timeout=self.cfg.timeout,\n            retry=self.cfg.retry,\n        )\n\n        return self\n\n    async def get_cli(self) -> str:\n        \"\"\"Get path to CLI.\"\"\"\n        if cli_bin := os.getenv(\"_EXPERIMENTAL_DAGGER_CLI_BIN\"):\n            return cli_bin\n\n        # Get from cache or download.\n        return await Downloader(progress=self.progress)\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/sdk/python/src/dagger/provisioning/_engine.py#L93-L129","documentation":"An ExceptionGroup raised when both the primary (downloaded CLI) and the fallback (CLI from PATH) provisioning attempts fail. The download failed earlier (download_error), and then starting/connecting to the PATH dagger binary also raised an exception. Both errors are surfaced together so the root causes aren't hidden.","triggerScenarios":"In provision(), after a failed download (download_error set), the code tries to start/connect using the PATH dagger binary cli_bin; any exception in that path is re-raised as ExceptionGroup([download_error, e]) with this combined message.","commonSituations":"Download blocked by network issues AND the PATH dagger is an incompatible/broken version that fails to start (e.g. engine version incompatibility, missing exec permission); both the pinned download and local binary unusable in restricted CI environments.","solutions":["Fix the first error in the group (the download failure) — network, proxy, or pinned version availability.","Verify the PATH dagger binary runs standalone (`dagger version`); reinstall or upgrade it if it errors.","Ensure the PATH CLI version is compatible with the SDK version you are using.","Remove conflicting DAGGER_SESSION_* env vars so provisioning starts a fresh engine.","In CI, pin a known-good dagger CLI install step so the fallback is healthy."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import shutil, subprocess\ndef path_cli_usable() -> bool:\n    b = shutil.which(\"dagger\")\n    if not b:\n        return False\n    try:\n        return subprocess.run([b, \"version\"], capture_output=True, timeout=10).returncode == 0\n    except Exception:\n        return False\n# if not path_cli_usable(): fix the local CLI before provisioning","typeGuard":null,"tryCatchPattern":"try:\n    async with dagger.Connection() as client:\n        ...\nexcept ExceptionGroup as eg:\n    for sub in eg.exceptions:\n        logger.error(\"provisioning failed: %r\", sub)\n    raise  # fix download network AND local dagger install","preventionTips":["Keep the PATH dagger CLI healthy and version-compatible with the SDK (`dagger version` must work).","Fix network/proxy issues so the primary download path succeeds.","Pin CLI and SDK versions together and upgrade them in lockstep.","Bake a working dagger CLI into CI images."],"tags":["python","provisioning","exceptiongroup","fallback","versioning"],"backgroundTag":"provision-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}