2.1 KiB
Gravitiny Engineering Issues & Resolution Log
This document records architectural hurdles, bugs, investigations, and verified solutions encountered during the engineering of Gravitiny Core and its applets ecosystem.
Issue #001: Nested Directory Unwrapping during Git Clone and Zip Extraction
- Component:
gravitiny.src.installer.AppletInstaller - Severity: High (Broken Shim Execution)
- Status: Resolved
Symptom
When running gravitiny <applet> through the manager, the applet executed successfully because local discovery scanned both workspace and user dotfiles. However, executing direct global shims (e.g. lex books) failed with:
C:\Users\al3ph\AppData\Local\Programs\Python\Python313\python.exe: can't open file 'C:\Users\al3ph\.gravitiny\applets\lex\main.py': [Errno 2] No such file or directory
Root Cause
When Gitea generates repository archive zips (e.g. https://git.luxhebros.com/beerslayer/lex/archive/main.zip), the zip payload contains a top-level directory matching the repository name (lex/). When extracted into ~/.gravitiny/applets/lex, this caused a nested directory structure:
~/.gravitiny/applets/lex/lex/main.py instead of ~/.gravitiny/applets/lex/main.py.
Additionally, Python's shutil.move(src, dst) moves the source folder inside the destination folder if the destination folder already exists.
Solution
- Added
AppletInstaller._flatten_if_nested(target_dir: Path)static helper method. - The method inspects the extracted destination folder. If
main.pyormanifest.jsonis missing from the root and a single nested subfolder exists, it elevates all children files/folders to the root oftarget_dirand removes the redundant nested folder. - Updated both
_clone_git_repoand_download_and_extract_zippipelines to invoke_flatten_if_nested.
Verification
Re-ran python main.py install lex and python main.py install sec. Confirmed that main.py is extracted directly to C:\Users\al3ph\.gravitiny\applets\lex\main.py. Verified that direct shim execution lex books runs cleanly and instantly.