{"record":{"id":"ebdb21b9b37d785b","repo":"XX-net/XX-Net","slug":"deleting-fail-s","errorCode":null,"errorMessage":"deleting fail: %s","messagePattern":"deleting fail: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/launcher/update_from_github.py","lineNumber":358,"sourceCode":"    local_versions.sort(key=lambda s: list(map(int, s[0].split('.'))), reverse=True)\n    return local_versions\n\n\ndef get_current_version_dir():\n    current_dir = os.path.split(root_path)[-1]\n    return current_dir\n\n\ndef del_version(version):\n    if version == get_current_version_dir():\n        xlog.warn(\"try to delect current version.\")\n        return False\n\n    try:\n        shutil.rmtree(os.path.join(top_path, \"code\", version))\n        return True\n    except Exception as e:\n        xlog.warn(\"deleting fail: %s\", e)\n        return False\n\n\ndef update_current_version(version):\n    start_script = os.path.join(top_path, \"code\", version, \"launcher\", \"start.py\")\n    if not os.path.isfile(start_script):\n        xlog.warn(\"set version %s not exist\", version)\n        return False\n\n    current_version_file = os.path.join(top_path, \"code\", \"version.txt\")\n    with open(current_version_file, \"w\") as fd:\n        fd.write(version)\n    return True\n\n\ndef restart_xxnet(version=None):\n    import module_init\n    module_init.stop_all()","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/launcher/update_from_github.py#L340-L376","documentation":"shutil.rmtree of code/<version> raised (the non-current version path); logged with the exception and del_version returns False so the UI shows deletion failed.","triggerScenarios":"Permission denied on files inside the old version dir, files locked by a still-running module, or the directory not existing / path mismatch on case-sensitive filesystems.","commonSituations":"Leftover process from the old version holding files; install dir owned by root after running with sudo; Windows file locks.","solutions":["Stop all XX-Net processes before deleting old versions.","Fix ownership/permissions: chmod -R or run the delete with adequate privileges.","Delete the directory manually (rm -rf code/<version>) and refresh the UI."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import os, stat\nd = os.path.join(top_path, 'code', version)\nif not os.path.isdir(d): raise FileNotFoundError(d)\nif not os.access(d, os.W_OK): raise PermissionError(d)","typeGuard":null,"tryCatchPattern":"try:\n    ok = del_version(version)\nexcept OSError as e:\n    log.warn('delete failed, will retry after restart: %r', e)","preventionTips":["Stop all XX-Net processes before cleanup.","Fix dir ownership before delete.","Delete manually if the API keeps failing."],"tags":["filesystem","permissions","version-management"],"backgroundTag":"rmtree-permission-denied","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}