fix: config.LOGS_DIR honors CCXRAY_HOME (banner + legacy migration)#50
Merged
Conversation
server/config.js hardcoded LOGS_DIR to ~/.ccxray/logs, ignoring CCXRAY_HOME while the storage layer resolved it correctly. This left config.LOGS_DIR (used by the startup banner and the one-time legacy-logs migration) pointing at the wrong directory whenever CCXRAY_HOME was set. Root cause was a duplicated path computation. Introduce server/paths.js as the single source of truth (resolveCcxrayHome/resolveLogsDir, precedence LOGS_DIR > CCXRAY_HOME > ~/.ccxray/logs) and have both config.js and storage/index.js resolve from it, so the banner and migration target can no longer drift from where logs are actually written. Also make the startup banner backend-aware: each storage adapter now exposes a display-only 'location' (local logs dir, or s3://bucket/prefix), so S3 setups no longer show a misleading local path. Tests: sanitize CCXRAY_HOME/LOGS_DIR/STORAGE_BACKEND in the config test child env, and add coverage for CCXRAY_HOME resolution, LOGS_DIR precedence, default fallback (HOME/USERPROFILE pinned), and storage-write/config drift. Closes #31
This was referenced Jun 6, 2026
lis186
added a commit
that referenced
this pull request
Jun 6, 2026
hub.js, settings.js, ratelimit-log.js, and auth.js each inlined the same 'process.env.CCXRAY_HOME || path.join(os.homedir(), ".ccxray")' expression. Replace all four with resolveCcxrayHome() from server/paths.js (introduced in #50), and drop the now-unused 'os' import in each. auth.js keeps the call inside getHubDir() so it still reads the env per call. Pure de-duplication — identical behavior, no precedence change. The CCXRAY_HOME contract is now enforced in one place, so it can't drift the way config.LOGS_DIR did in #31. Closes #51
This was referenced Jun 7, 2026
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.
Closes #31.
Problem
server/config.jshardcodedLOGS_DIR = ~/.ccxray/logs, ignoringCCXRAY_HOMEeven though the storage layer (server/storage/index.js) resolved it correctly. WithCCXRAY_HOMEset,config.LOGS_DIR— used by the startup banner and the one-time legacy-logs migration — pointed at the wrong directory.Root cause
The logs path was computed independently in two places, so they drifted.
Fix
server/paths.jsas single source of truth:resolveCcxrayHome()/resolveLogsDir(), precedenceLOGS_DIR>CCXRAY_HOME>~/.ccxray/logs(mirrors the storage layer's historical resolution exactly).config.jsandstorage/index.jsboth resolve from it → banner + migration target can no longer drift from where logs are written.location(local logs dir, ors3://bucket/prefix), so S3 setups stop showing a misleading local path.Tests
runSnippetnow sanitizesCCXRAY_HOME/LOGS_DIR/STORAGE_BACKENDso ambient shell/hub env can't corrupt results.CCXRAY_HOMEhonored,LOGS_DIRprecedence, default fallback (HOME+USERPROFILEpinned to temp, cross-platform), and an end-to-end write provingconfig.storagelands files underconfig.LOGS_DIR(no drift).Reviewed
Codex (gpt-5.5, xhigh) — no blockers; two minor polish items applied (cross-platform HOME pinning, honest
paths.jscomment).Not in this PR (tracked separately)
hub.js,settings.js,ratelimit-log.js,auth.jsstill duplicate theCCXRAY_HOMEhome-dir resolution inline — candidates for consolidation intopaths.js. Kept out to keep this PR focused on config.LOGS_DIR does not honor CCXRAY_HOME (banner + legacy migration use wrong path) #31.@aws-sdk/client-s3not being installed in dev).