Repository navigation
Find the home and the data directory on Windows too - #115
Merged
Merged
Conversation
Both of these resolved through `HOME`, and Windows does not set it. They
are also two different directories, which is easy to miss because on unix
one sits inside the other:
- the data directory holds the configuration, the request store, the
lock, the socket and the token. Its last resort was a relative
`.thinkwatch`, so on Windows the whole thing would have landed in
whatever the process's working directory happened to be.
- the user's home is only ever used to go looking for other clients'
configuration -- `~/.claude`, `~/.codex`, `~/.cursor` -- and those
dot-directories do live under `%USERPROFILE%` on Windows.
So the data directory follows the platform's own habit (`%APPDATA%\
ThinkWatch`, not `%USERPROFILE%\.thinkwatch`: a leading dot is a unix
convention, and someone looking for what a program stored on Windows
looks in APPDATA), while the home keeps meaning the home and reads
`USERPROFILE` there.
The choice between the two habits is a parameter rather than an inline
`cfg!`, so both branches are exercised on any machine. The CI only has
macOS today, and the branch nobody runs is exactly the one that would be
wrong.
`twcore` had grown its own second copy of `home()`. It now asks
tw-control, because "what is the home" having two answers in two places
is the same bug this commit is fixing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Both of these resolved through
HOME, and Windows does not set it.They are also two different directories, which is easy to miss because on unix one sits inside the other:
tw_config::default_dir.thinkwatch%APPDATA%\ThinkWatchtw_control::home_dir%USERPROFILE%The data directory's fallback is the sharper of the two: on Windows the whole thing would have landed in whatever the process's working directory happened to be, silently.
Why they resolve differently
The data directory follows the platform's own habit —
%APPDATA%\ThinkWatch, not%USERPROFILE%\.thinkwatch. A leading dot is a unix convention, and someone looking for what a program stored on Windows looks in APPDATA.The home keeps meaning the home.
~/.claude,~/.codexand~/.cursorreally do live under%USERPROFILE%there, so adoption still finds them.Testing a branch this machine cannot run
The choice between the two habits is a parameter (
Convention::Unix/Convention::Windows) rather than an inlinecfg!, so both branches are exercised on any host. CI only has macOS today, and the branch nobody runs is exactly the one that would be wrong. Six tests cover: the explicit override winning on either platform, each platform reading only its own variable (a machine with Git Bash hasHOMEset and is Windows — that must not change where data goes), an empty variable counting as unset, and the no-information case staying relative rather than falling to the root.One duplicate collapsed
twcorehad grown its own second copy ofhome(), readingHOMEdirectly. It now asks tw-control — "what is the home" having two answers in two places is the same bug this PR is fixing.Verified
cargo clippy --workspace --all-targets -- -D warningsclean, full workspace test suite green.🤖 Generated with Claude Code