Skip to content

fix(paths): cross-platform path resolution & env var support - #5

Open
Anstarc wants to merge 1 commit into
ZedeX:mainfrom
Anstarc:fix/cross-platform-paths
Open

fix(paths): cross-platform path resolution & env var support#5
Anstarc wants to merge 1 commit into
ZedeX:mainfrom
Anstarc:fix/cross-platform-paths

Conversation

@Anstarc

@Anstarc Anstarc commented Aug 19, 2026

Copy link
Copy Markdown

Previously Trae data/install dirs were hardcoded to Windows paths (~/AppData/Roaming/Trae CN, ~/AppData/Local/Programs/Trae-CN), which broke on macOS/Linux and non-default installs. The env override in scripts/fetch-models-vscdb.js was also ineffective because .env was never loaded when run standalone.

  • Add src/paths.js: centralized resolver with per-OS base dirs (Windows %APPDATA%/%LOCALAPPDATA%, macOS ~/Library/Application Support and /Applications, Linux $XDG_CONFIG_HOME and /opt) and env overrides: TRAE_EDITION, TRAE_DATA_DIR, TRAE_DATA_DIR, TRAEFOLDER, TRAE*_INSTALL_FOLDER.
  • Refactor auth.js, trae-decrypt.js, scripts/fetch-models-vscdb.js to consume paths.js, removing all hardcoded Windows-only paths and the cnPath/sgPath copy-paste dead code in trae-decrypt.js.
  • Load .env via dotenv in fetch-models-vscdb.js so TRAE_*_DATA_DIR (and other vars) are honored when the script runs standalone.
  • Document all new env vars in .env.example.

Previously Trae data/install dirs were hardcoded to Windows paths
(~/AppData/Roaming/Trae CN, ~/AppData/Local/Programs/Trae-CN),
which broke on macOS/Linux and non-default installs. The env override
in scripts/fetch-models-vscdb.js was also ineffective because .env
was never loaded when run standalone.

- Add src/paths.js: centralized resolver with per-OS base dirs
  (Windows %APPDATA%/%LOCALAPPDATA%, macOS ~/Library/Application Support
  and /Applications, Linux $XDG_CONFIG_HOME and /opt) and env
  overrides: TRAE_EDITION, TRAE_*_DATA_DIR, TRAE_DATA_DIR,
  TRAE_*_FOLDER, TRAE_*_INSTALL_FOLDER.
- Refactor auth.js, trae-decrypt.js, scripts/fetch-models-vscdb.js to
  consume paths.js, removing all hardcoded Windows-only paths and the
  cnPath/sgPath copy-paste dead code in trae-decrypt.js.
- Load .env via dotenv in fetch-models-vscdb.js so TRAE_*_DATA_DIR
  (and other vars) are honored when the script runs standalone.
- Document all new env vars in .env.example.

Non-default Trae installations and non-Windows platforms now work
without code changes.
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.

1 participant