Repository navigation
Allow relocating Aegisub's files with environment variables - #731
Draft
CoffeeFlux wants to merge 1 commit into
Draft
CoffeeFlux wants to merge 1 commit into
CoffeeFlux wants to merge 1 commit into
Conversation
CoffeeFlux
marked this pull request as draft
October 9, 2026 04:52
AEGISUB_DATA_DIR replaces ?data (the bundled files), AEGISUB_USER_DIR is used for all per-user files (settings, scripts, logs and caches) instead of the platform's default locations, and AEGISUB_CONFIG is the config file to use instead of the one in the user dir. This makes it possible to run an uninstalled build against the source tree, which the upcoming CLI tests need now that the Lua support modules are only loaded from ?data, and to run Aegisub with a clean profile without touching the real one. An explicit AEGISUB_USER_DIR takes precedence over portable mode on Windows. Both now go through Path::SetUserDir, so that any per-user directories added in the future only need to be handled in one place. The directory variables are ignored with a warning if they point at a file, since agi::Path would otherwise silently use its parent directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CoffeeFlux
force-pushed
the
env-path-overrides
branch
from
October 10, 2026 17:34
0e19d1f to
1ea12a7
Compare
This branch has not been deployed
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.
Adds three environment variables, read once at startup:
AEGISUB_DATA_DIR?data, the bundled files (automation includes and autoload, etc.)AEGISUB_USER_DIRAEGISUB_CONFIGEmpty values count as unset, and relative paths are resolved against the working directory at startup.
Why
?datais compiled in as the install prefix. Since the Lua support modules (moonscript.luaetc.) are now only loaded from?data, an uninstalled build can't run automation scripts.AEGISUB_DATA_DIR=<source tree>fixes that, and the CLI end-to-end tests in Headless CLI #670 need it.AEGISUB_USER_DIRgives a throwaway or per-project profile without touching the real one, the wayBLENDER_USER_RESOURCES,KICAD_CONFIG_HOMEor Chrome's--user-data-dirdo. Headless CLI #670 will add matching command-line flags for CLI mode, using the same code.Details
One place for the per-user directories.
AEGISUB_USER_DIRand Windows portable mode both go through the newagi::Path::SetUserDir, which currently points?userand?localat the given directory. Caches move along with everything else; mpv's--config-diris a known trap for not doing that. Any per-user directories added later then only need adding there. For example, #264's?stateneeds to be, orAEGISUB_USER_DIRand portable mode would leave logs and autosaves in the default location.Precedence:
AEGISUB_USER_DIR, then Windows portable mode (aconfig.jsonnext to the executable), then the platform default.AEGISUB_CONFIGapplies whichever user dir wins, so it can be combined with a clean user dir.?dictionaryisn't moved byAEGISUB_DATA_DIR, even on platforms where it's derived from?data.Directories that are files. If
AEGISUB_DATA_DIRorAEGISUB_USER_DIRpoints at a file, it's ignored with a warning in the log. Otherwiseagi::Pathwould silently use the file's parent directory.Testing
Tested on macOS with the GUI:
hotkey.jsonwere created in the given user dir, the config was read from the given file, and an autoload script in the given data dir'sautomation/autoloadwas loaded. Nothing new appeared in the real profile.AEGISUB_USER_DIRpointing at a file, the warning was logged and the default location used.The Windows-specific bits (
_wgetenvand the portable-mode precedence) are only compile-tested by CI.🤖 Generated with Claude Code