Skip to content

fix: allow cache subcommand when ./cache is a directory (fixes #1726)#3743

Open
leno23 wants to merge 2 commits into
sharkdp:masterfrom
leno23:fix/cache-subcommand-when-cache-dir-exists-1726
Open

fix: allow cache subcommand when ./cache is a directory (fixes #1726)#3743
leno23 wants to merge 2 commits into
sharkdp:masterfrom
leno23:fix/cache-subcommand-when-cache-dir-exists-1726

Conversation

@leno23

@leno23 leno23 commented May 16, 2026

Copy link
Copy Markdown

Summary

bat cache --build failed on the second run when BAT_CACHE_PATH pointed to a ./cache directory in the current working directory:

error: Found argument '--build' which wasn't expected

The cache subcommand was disabled whenever Path::new("cache").exists(), including when cache is a directory created by the previous build.

Fix

Only disable the cache subcommand when cache is a file in the working directory (is_file()), matching the original intent in the comment.

Tests

  • Added cache_build_twice_when_cache_directory_exists_in_cwd integration test

Fixes #1726.

leno23 and others added 2 commits May 17, 2026 02:05
Only treat a file named `cache` in the working directory as a file
to open; a `cache` directory must not hide the `bat cache` subcommand.

Fixes sharkdp#1726.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@leno23

leno23 commented May 16, 2026

Copy link
Copy Markdown
Author

CI is green on my side (including integration test cache_build_twice_when_cache_directory_exists_in_cwd).

Ready for review when you have time — thanks!

@leno23

leno23 commented May 16, 2026

Copy link
Copy Markdown
Author

CI still green — ready for review when convenient. Thanks!

leno23 added a commit to leno23/bat that referenced this pull request May 16, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@leno23

leno23 commented May 16, 2026

Copy link
Copy Markdown
Author

Friendly ping — CI is green and this is a small, focused fix for #1726. Happy to adjust if anything is needed. Thanks!

@leno23

leno23 commented May 16, 2026

Copy link
Copy Markdown
Author

Friendly ping — small focused fix for #1726, CI green. Thanks for any review when you have time.

@leno23

leno23 commented May 16, 2026

Copy link
Copy Markdown
Author

CI remains green. Gentle ping when convenient — fixes bat cache when a ./cache directory exists. Thanks!

@leno23

leno23 commented May 16, 2026

Copy link
Copy Markdown
Author

Friendly ping — bat cache when ./cache is a directory; CI green. Thanks!

@leno23

leno23 commented May 16, 2026

Copy link
Copy Markdown
Author

@sharkdp Friendly ping — bat fixes #3743#3748 are all CI-green when convenient. Latest: #3748 fixes --decorations=auto when piping with --color=always (#3710).

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.

Errors for bat cache --build when cache already exists and BAT_CACHE_PATH is specified

1 participant