Skip to content

UI installer fails on paths with spaces and crashes with IndexError #15

@Shorzinator

Description

@Shorzinator
  • Environment: macOS (Darwin 24.6.0), Node/electron-packager per src/ui/package.json

  • Steps to reproduce:

    1. Clone repo into a directory with spaces in the path.
    2. Run ./install.sh --prefix=./install --enable_ui.
  • Observed:

    • IndexError: list index out of range at install.py when scanning for OpenLeetCodeUI-*-*.
  • Root causes:

    • electron-packager --out path wasn’t quoted, so packaging output could fail with spaces in path.
    • Installer assumed a match existed and indexed [0] unguarded.
  • Fix:

    • Quote --out path in cmd_npx_build.
    • Check for matches before indexing and raise a clear error message if none.
  • Bold fix: Quote the UI output path in the electron-packager command to support spaces in directories (e.g., “Interview Prep”).

-    cmd_npx_build = f"npx electron-packager . --out={install_dir} --overwrite"
+    cmd_npx_build = f"npx electron-packager . --out=\"{install_dir}\" --overwrite"
  • Bold fix: Make the UI artifact discovery robust. Previously it assumed at least one directory matched OpenLeetCodeUI-*-* and crashed with IndexError. Now it checks for matches and raises a clear error if none are found, including directory listing and the command used.
-    openleetcode_ui_dir = os.path.join(
-        install_dir,
-        [
-            d for d in os.listdir(install_dir)
-            if fnmatch.fnmatch(d, "OpenLeetCodeUI-*-*")
-        ][0]
-    )
+    matches = [
+        d for d in os.listdir(install_dir)
+        if fnmatch.fnmatch(d, "OpenLeetCodeUI-*-*")
+    ]
+    if not matches:
+        listing = "\n".join(sorted(os.listdir(install_dir)))
+        raise RuntimeError(
+            "electron-packager produced no output directory matching 'OpenLeetCodeUI-*-*'.\n"
+            f"Install dir contents:\n{listing}\n"
+            f"Command run: {cmd_npx_build}"
+        )
+    openleetcode_ui_dir = os.path.join(install_dir, matches[0])

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions