{"record":{"id":"fbc8ed2be70f0efb","repo":"unslothai/unsloth","slug":"a-transformers-installation-is-replacing-the-lates","errorCode":null,"errorMessage":"A transformers installation is replacing the latest sidecar; retry when it completes.","messagePattern":"A transformers installation is replacing the latest sidecar; retry when it completes\\.","errorType":"exception","errorClass":"SidecarSwapInProgress","httpStatus":409,"severity":"warning","filePath":"studio/backend/core/export/orchestrator.py","lineNumber":225,"sourceCode":"    # Subprocess lifecycle\n    # ------------------------------------------------------------------\n\n    def _spawn_subprocess(self, config: dict) -> None:\n        \"\"\"Spawn a new export subprocess.\"\"\"\n        # Last-resort recheck for spawns outside an active op. Inside an op, _export_active is set and\n        # load_checkpoint already rechecked, so a reservation here is an install about to observe\n        # is_export_active() and abort; raising would kill this export for an install that never proceeds.\n        from utils.transformers_version import sidecar_swap_in_progress\n\n        from utils.transformers_version import sidecar_swap_kind\n\n        _swap_kind = sidecar_swap_kind()\n        # Inside an active op an INSTALL reservation is about to abort on the\n        # is_export_active check, but a lazy REPAIR has no such check and can be\n        # rebuilding the sidecar right now, so it must always refuse the spawn.\n        if _swap_kind == \"repair\" or (_swap_kind is not None and not self._export_active):\n            from utils.transformers_version import SidecarSwapInProgress\n            raise SidecarSwapInProgress(\n                \"A transformers installation is replacing the latest sidecar; \"\n                \"retry when it completes.\"\n            )\n        from utils.native_path_leases import (\n            native_path_secret_removed_for_child_start,\n            run_without_native_path_secret,\n        )\n        from utils.hf_cache_settings import child_environment_for_spawn, get_hf_cache_paths\n\n        cache_env = get_hf_cache_paths().child_env({})\n\n        with (\n            child_environment_for_spawn(cache_env),\n            native_path_secret_removed_for_child_start(),\n        ):\n            self._cmd_queue = _CTX.Queue()\n            self._resp_queue = _CTX.Queue()\n","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/export/orchestrator.py#L207-L243","documentation":"SidecarSwapInProgress raised by the export orchestrator before spawning the export sidecar when utils.transformers_version reports a sidecar swap in progress: either a lazy REPAIR is actively rebuilding the sidecar, or an INSTALL reservation exists while no export is active. Spawning an export against a sidecar that is being replaced would pin or observe a half-swapped transformers installation, so the caller is told to retry after the swap completes.","triggerScenarios":"A transformers version install/repair starting concurrently with an export request (install about to observe is_export_active() and abort, but a repair has no such check); a lazy repair triggered by the version manager rebuilding the sidecar exactly when a new export spawns; frequent transformers version switching in the UI racing exports.","commonSituations":"Users switching transformers versions while queued exports fire; first export after an upgrade triggering a lazy sidecar repair; automation that installs transformers versions and exports in quick succession.","solutions":["Retry the export after the transformers install/repair completes (the error is deliberately transient).","Avoid initiating transformers version installs/switches while exports are queued or running.","Operators: if it persists, inspect sidecar_swap_kind()/the swap state to see whether a repair is stuck.","Surface the message to the user as 'retry shortly' rather than a hard failure."],"exampleFix":"# before\nresult = orchestrator.run_export(cfg)\n\n# after\nfor attempt in range(5):\n    try:\n        result = orchestrator.run_export(cfg)\n        break\n    except SidecarSwapInProgress:\n        time.sleep(10)  # transformers install is replacing the sidecar; retry\nelse:\n    raise RuntimeError('sidecar swap never completed')","handlingStrategy":"retry","validationCode":"from utils.transformers_version import sidecar_swap_in_progress\nif sidecar_swap_in_progress():\n    wait_for_swap_to_finish()  # or defer the export","typeGuard":null,"tryCatchPattern":"try:\n    orchestrator.run_export(cfg)\nexcept SidecarSwapInProgress:\n    schedule_retry(delay=10)  # transient: transformers install is replacing the sidecar","preventionTips":["Do not start exports while transformers version installs/switches are in flight.","Classify SidecarSwapInProgress as retryable in orchestrating code and UIs.","Surface 'retry when it completes' messaging instead of a hard failure."],"tags":["concurrency","transformers","export","retry","studio"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}