Skip to content

[karthik] fix: resolve debugger filepath-not-found on Linux#59

Open
Karthik-MP wants to merge 1 commit into
openswarm-ai:devfrom
Karthik-MP:karthik/fix/debugger-linux-case-sensitive-path
Open

[karthik] fix: resolve debugger filepath-not-found on Linux#59
Karthik-MP wants to merge 1 commit into
openswarm-ai:devfrom
Karthik-MP:karthik/fix/debugger-linux-case-sensitive-path

Conversation

@Karthik-MP

Copy link
Copy Markdown

What

Fixes Filepath not found: <lowercase-path> spam on Linux startup, and the debugger failing to index any mixed-case file (e.g. Apps.py, Directory.py).

Closes #58.

Root cause

Two .lower() calls interacted to silently break the debugger on Linux:

debugger/debugger_backend/Directory.py:44

# Before
child_abspath = os.path.join(root_dir, child.path).lower()
if os.path.isfile(child_abspath):   # Always False on Linux for mixed-case names
    ordered_abspaths.append(...)    # Never reached → file not indexed

os.path.isfile("apps.py") returns False on Linux when the real file is Apps.py. Files are silently dropped from the index.

debugger/debugger_backend/Debugleton.py:78

# Before
filepath = filepath.lower()
filepath_id = self.abspaths.index(filepath)  # No match → "Filepath not found"

macOS HFS+/APFS is case-insensitive so both sides match regardless — the bug is invisible there.

Fix

Store real filesystem paths always. On darwin only, lowercase both the stored list and the lookup at compare time.

# Directory.py — remove .lower() before existence check
child_abspath = os.path.join(root_dir, child.path)

# Debugleton.py — platform-aware comparison
if sys.platform == "darwin":
    abspaths = [p.lower() for p in self.abspaths]
    filepath_id = abspaths.index(filepath.lower())
else:
    filepath_id = self.abspaths.index(filepath)

Test

Run bash backend/run.sh on Linux — no more Filepath not found lines on startup.

On Linux (case-sensitive FS), Directory.py lowercased child paths
before os.path.isfile(), so mixed-case files like Apps.py were never
indexed. Debugleton.py then lowercased the lookup too, guaranteeing
no match. Fix: store real paths always; on darwin only, lowercase
both sides at compare time. Closes openswarm-ai#58.
@Karthik-MP

Copy link
Copy Markdown
Author

Fix summary

Stop lowercasing filesystem paths. Store and compare real (original-case) paths everywhere; only fold case on macOS, where the filesystem is case-insensitive.

Directory.py — store the real path so os.path.isfile succeeds for mixed-case files on Linux:

child_abspath = os.path.join(root_dir, child.path)

Debugleton.py — case-fold both sides only on macOS:

if sys.platform == "darwin":
    abspaths = [p.lower() for p in self.abspaths]
    filepath_id = abspaths.index(filepath.lower())
else:
    filepath_id = self.abspaths.index(filepath)

The caller (debug.py) passes os.path.abspath(code.co_filename), the real absolute path. On Linux it now matches the real-case index exactly; on macOS both sides are lowercased so case drift still matches.

Behavior matrix

Platform Filesystem Index step Lookup step
Linux case-sensitive real path, isfile ok exact match
macOS case-insensitive real path, isfile ok lowercase both sides

Verification

  • os.path.isfile("/tmp/ctest/apps.py") -> False (old, buggy path)
  • os.path.isfile("/tmp/ctest/Apps.py") -> True (new, real path)
  • Lookup logic tested both branches: Linux matches real case and rejects wrong case; darwin matches regardless of case.

Note

debugger/build/lib/... is a tracked setuptools build artifact that still holds the pre-fix code. It is not on the runtime import path (runtime imports debugger_backend, not build.lib.debugger_backend), so it does not affect behavior. Suggest a follow-up to git rm -r debugger/build and gitignore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant