claude: fall back to a temp dir when the libhegel cache is unwritable - #13
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See hegeldev/hegel-go#116
Claude-written description
Ports hegeldev/hegel-go#116 (fixing hegeldev/hegel-go#115) to hegel-java.
LibraryLoaderpreviously refused to load if it could not write the bundled libhegel to the per-user cache directory (~/.cache/hegel-java/libhegel/<sha256>/), so sandboxes that deny writes outside the workspace — e.g. Codex's macOS seatbelt policy — could not run hegel tests at all, even though the cache is purely a performance optimization.The cache is now best-effort:
unpackBundledtries the content-hash-keyed per-user cache first (unchanged semantics: reuse if present, atomic temp-file-plus-rename install); on any cache failure it silently extracts the native to a fresh directory under the system temp dir (Files.createTempDirectory) and loads from there, leaving reclamation to the OS's temp cleaning. Loading fails only when both paths fail, with an error reporting both causes — the temp failure as the exception's cause and the cache failure in the message plus as a suppressed exception, so both stack traces survive. The temp fallback needs no locking or permission hardening since the directory is fresh, unique, and private per process.The temp-dir supplier is injected via a new constructor overload so both new paths are unit-tested: cache unwritable → temp fallback succeeds (through the real default supplier), and cache + temp both failing → error mentions both causes.