Conversation
macOS cleans up tempdir() files after 3 days of inactivity, causing
compound registrations saved with add_reglist(temp=TRUE) to disappear
during long-running R sessions.
Changed to use tools::R_user_dir("nat.templatebrains", "cache") with
session-specific subfolders (using basename(tempdir()) as session ID).
A marker file stores the original tempdir path, and stale session
folders are cleaned up when a new session detects the original
tempdir no longer exists.
This requires R >= 4.0 (updated in DESCRIPTION).
jefferis
force-pushed
the
fix/persistent-reglist-cache
branch
from
March 8, 2026 00:10
3f5faaf to
7c1ad53
Compare
jefferis
added a commit
that referenced
this pull request
Mar 8, 2026
Replaces disk-based storage in tempdir with in-memory caching via cachem::cache_mem(). This avoids macOS tempdir cleanup issues during long-running R sessions. Key changes: - add_reglist(temp=TRUE) now stores serialized reglists in memory - Serialization breaks environment references, avoiding memory leaks - allreg_dataframe() includes memory-cached entries with memory:// prefix - make_reglist() handles memory:// paths in bridging sequences Benefits: - CRAN compliant (no file system writes) - No tempdir cleanup issues on any platform - Simpler than disk-based caching See also PR #53 for alternative disk-based approach (superseded by this).
2 tasks
jefferis
added a commit
that referenced
this pull request
Mar 8, 2026
Replaces disk-based storage in tempdir with in-memory caching via cachem::cache_mem(). This avoids macOS tempdir cleanup issues during long-running R sessions. Key changes: - add_reglist(temp=TRUE) now stores serialized reglists in memory - Serialization breaks environment references, avoiding memory leaks - allreg_dataframe() includes memory-cached entries with memory:// prefix - make_reglist() handles memory:// paths in bridging sequences Benefits: - CRAN compliant (no file system writes) - No tempdir cleanup issues on any platform - Simpler than disk-based caching See also PR #53 for alternative disk-based approach (superseded by this).
jefferis
added a commit
that referenced
this pull request
Mar 8, 2026
Replaces disk-based storage in tempdir with in-memory caching using a simple environment. This avoids macOS tempdir cleanup issues during long-running R sessions. Key changes: - add_reglist(temp=TRUE) now stores serialized reglists in memory - Serialization breaks environment references, avoiding memory leaks - allreg_dataframe() includes memory-cached entries with memory:// prefix - make_reglist() handles memory:// paths in bridging sequences Benefits: - CRAN compliant (no file system writes) - No tempdir cleanup issues on any platform - Simpler than disk-based caching - No new dependencies (uses base R environment) See also PR #53 for alternative disk-based approach (superseded by this).
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.
Summary
tempdir()files after 3 days of inactivity, causing compound registrations saved withadd_reglist(temp=TRUE)to disappear during long-running R sessionstools::R_user_dir("nat.templatebrains", "cache")with session-specific subfoldersbasename(tempdir())(e.g.,RtmpeWpUOg).tempdir_pathmarker file tracks the original tempdir, and stale session folders are cleaned up when a new session detects the original tempdir no longer existsHow it works
add_reglist(temp=TRUE), files go to~/.../cache/nat.templatebrains/tempreglists/RtmpXXXXX/.tempdir_pathmarker stores the full originaltempdir()pathcleanup_stale_reglist_sessions()checks each session folder's markerTest plan
.tempdir_pathmarker is written🤖 Generated with Claude Code