document-skills: soffice.py crashes on Windows (AF_UNIX AttributeError)
Bug
The office/soffice.py helper shipped with the docx, pptx, and xlsx document-skills crashes on Windows with:
AttributeError: module 'socket' has no attribute 'AF_UNIX'
Root cause
_needs_shim() unconditionally calls socket.socket(socket.AF_UNIX, ...) to test whether Unix domain sockets are available. On Windows, the AF_UNIX constant doesn't exist as a Python attribute, so it throws AttributeError instead of the expected OSError.
The shim itself (LD_PRELOAD + compiled C .so) is Linux-only and irrelevant on Windows, but the detection code runs before it can be skipped.
Affected files
All three copies are identical and have the same bug:
skills/docx/scripts/office/soffice.pyskills/pptx/scripts/office/soffice.pyskills/xlsx/scripts/office/soffice.py
Additionally, skills/docx/scripts/accept_changes.py has two Windows-incompatible assumptions:
- Hardcoded
/tmp/path for the LibreOffice profile directory — resolves toC:\tmp\on Windows instead of the actual temp directory file://URI construction — producesfile://C:\Users\...instead of thefile:///C:/Users/...format LibreOffice expects on Windows
Suggested fix
soffice.py — Add an early return in _needs_shim():
def _needs_shim() -> bool:
if os.name == "nt":
return False
try:
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.close()
return False
except OSError:
return True
accept_changes.py — Use tempfile.gettempdir() for the profile path and build the file:// URI with platform-aware formatting:
LIBREOFFICE_PROFILE = str(Path(tempfile.gettempdir()) / "libreoffice_docx_profile")
def _profile_file_uri() -> str:
p = Path(LIBREOFFICE_PROFILE).resolve()
if os.name == "nt":
return "file:///" + p.as_posix()
return "file://" + str(p)
Environment
- Windows 11 (no WSL)
- Python 3.12
- LibreOffice 25.8
- Claude Code with document-skills plugin (cache hash
1ed29a03dc85)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗