def assert_correct_mode()

in linux/cuda_installer/os_installers/__init__.py [0:0]


    def assert_correct_mode(mode: str):
        """
        Check if the previously used installation method is the same as current one. If it's not, abort the process and
        display a message about the problem.
        """
        mode_file = INSTALLER_DIR / "mode"

        if not mode_file.exists():
            # First run, no mode file exists, we make it and set the mode
            mode_file.write_text(mode)
            return

        # There was a previous mode, need to make sure, we're in the same mode.
        prev_mode = mode_file.read_text().strip()
        if prev_mode == mode:
            return

        logger.error(
            f"Previous installations using '{prev_mode}' detected, that's different than requested '{mode}' mode. You can't switch installation modes, try again in '{prev_mode}' mode or with a clean system."
        )
        assert f"You have to use {prev_mode} in this system."