Repository navigation
fix(util): use a per-user tmp directory - #52973
Shalin-Shah-2002 wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HfXsWoKF5h7tmdmyUEw1rD
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Fixes #50259
Type of change
What does this PR do?
The global tmp directory is
os.tmpdir()/opencode, one fixed name shared by every user of a machine, and the Global layer runsmkdiron it at startup. If anything else already owns that name, startup fails for everyone withEEXIST: file already exists, mkdir '/tmp/opencode', which is the error in the issue (the reporter's/tmp/opencodeis a 0-byte file). If another user owns it as a directory, startup passes but later writes into it can fail.On POSIX the tmp directory is now
opencode-<uid>, so it can't collide with another user's or a stray entry. Windows already has a per-user temp directory and keepsopencode. The tmp path is read throughGlobal, so the permission whitelist and the instructions text pick up the new name without other changes.I don't know what created the stray file in the report, so this fixes the shared name and the crash, not that original cause. Anything that was left in the old
/tmp/opencodeis not migrated; it is only scratch space.How did you verify your code works?
Added a test in
packages/util/test/global.test.tsthat puts a regular file namedopencodeinTMPDIRand builds the Global layer. Before the change it fails with the issue'sEEXIST; after, it passes. The existing tests that pinned…/opencode(global-roots.test.ts,global.test.ts,cli/test/service.test.ts) now expectopencode-<uid>.packages/util: 91 pass.packages/clitest/service.test.ts: 21 pass. Typecheck is clean in both, and the pre-push check passed. With a stray file at$TMPDIR/opencode,opencode debug pathsnow exits 0 and reportstmpas…/opencode-501.I could only test on macOS with one user, so I simulated the occupied name with a file instead of a second Unix user.
Screenshots / recordings
N/A
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01HfXsWoKF5h7tmdmyUEw1rD