Skip to content

Conversation

@Cervator
Copy link
Member

@Cervator Cervator commented Nov 27, 2025

The new Antigravity IDE by Google and Gemini 3 Pro found this one while I was trying to write Terasology tests validating various ways to get resources. It sounded reasonable and tested out - will let the AI explain further! Leaving this in a PR just so I don't forget the what and why, it doesn't need to merge any time soon.

Explanation of the Gestalt Fix

The issue was in ClasspathFileSource.buildPathString(), which was unconditionally appending a slash (/) to the path.

  • The Mechanism: getFile(path) calls buildPathString(path) and then classLoader.getResource(fullPath).
  • The Problem:
    • For Directories: A trailing slash is fine (and often correct).
    • For Files on Disk: Most OS filesystems are lenient and ignore the trailing slash.
    • For Files in JARs: The JarURLConnection / ClassLoader is strict. path/to/file.txt exists, but path/to/file.txt/ implies a directory named file.txt, which does not exist.
  • Why it failed: When running from source (loose files), the OS likely handled the trailing slash gracefully. When running with the engine as a JAR (which ModuleLoadingTest seems to be doing for the engine module), the strict JAR lookup failed.

Is it safe? Yes. getFile() returns a FileReference, which is intended for reading files (it has an open() method for streams). It is not typically used for directories. Even if it were, ClassLoader.getResource generally handles directory paths without trailing slashes correctly anyway. The fix simply constructs the path exactly as requested for getFile, bypassing the directory-oriented helper.


Note

Adjusts ClasspathFileSource to only append a trailing slash for directories, not files.

  • gestalt-module:
    • ClasspathFileSource:
      • Change buildPathString(List<String> path) to buildPathString(List<String> path, boolean isDirectory).
      • getFile(...) now calls buildPathString(..., false) (no trailing slash for files).
      • getFilesInPath(...) and getSubpaths(...) now call buildPathString(..., true) (trailing slash for directories).
      • Path construction now appends "/" only when isDirectory is true.

Written by Cursor Bugbot for commit e309888. This will update automatically on new commits. Configure here.

@Cervator
Copy link
Member Author

... I did not realize just linking my GitHub with Cursor would auto-enable Bugbot here but alright, cool, till I run out of quota I guess 🤔

Copy link
Contributor

@BenjaminAmos BenjaminAmos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes make sense to me. Since the changes only affect an internal helper method, this should not break anything.

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.

3 participants