Skip to content

Conversation

@hugoduncan
Copy link
Member

Summary

When using git worktrees, it is very easy to remove the worktree before a REPL running in that directory is closed. Currently in this case, CIDER complains the cider-history file cannot be written and errors.

This PR modifies cider-repl--history-write so that if the file is not writable due to the parent directory no longer existing, it emits a warning via message and skips writing the file (returns early without error).

Changes

  • Modified cider-repl--history-write to check if parent directory exists when file is not writable
  • If parent directory missing: emit warning and return early (no error)
  • If parent exists but file not writable: keep existing error behavior
  • Added buttercup tests for history write edge cases

Commits

  • 7bb8f848 fix: Handle missing parent directory in history write
  • 8ed71452 test: Add tests for history write edge cases

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (eldev test)
  • All code passes the linter (eldev lint)
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the user manual (if adding/changing user-visible functionality)

When the parent directory of the history file no longer exists (common
when using git worktrees that get removed while CIDER is running),
emit a warning instead of throwing an error.

This allows CIDER to close gracefully when the worktree directory
has been deleted.
Add buttercup tests for cider-repl--history-write covering:
- Normal write succeeds (baseline)
- Parent directory missing emits warning, returns gracefully
- File not writable but parent exists raises error
@bbatsov
Copy link
Member

bbatsov commented Jan 16, 2026

One test seems to be failing:

cider-repl--history-write when file is not writable but parent directory exists raises an error
FAILED: Expected `(cider-repl--history-write history-file)' to throw a child signal of `error', but instead it returned `("(+ 1 2)")'

Root user bypasses file permissions, causing file-writable-p to
return t even for 444 files. Mock file-writable-p only when
running as root to allow the test to pass in CI environments
(which typically run as root) while still testing real file
permissions on normal systems.
@hugoduncan hugoduncan force-pushed the 1-make-cider-close-robust branch from 2197317 to 90dedf4 Compare January 16, 2026 12:34
@bbatsov bbatsov merged commit 15bd3b0 into master Jan 16, 2026
13 of 15 checks passed
@bbatsov
Copy link
Member

bbatsov commented Jan 16, 2026

Thanks!

I've fixed separate the outdated macOS images that were causing unrelated failures.

@alexander-yakushev alexander-yakushev deleted the 1-make-cider-close-robust branch January 16, 2026 15:20
@hugoduncan
Copy link
Member Author

Thank you :)

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.

3 participants