bat icon indicating copy to clipboard operation
bat copied to clipboard

bat cache doesn't seem to work when running in tmux

Open fschoenm opened this issue 2 years ago • 3 comments

What steps will reproduce the bug?

I'm using tmux.

When calling bat it shows this error:

[bat error]: The binary caches for the user-customized syntaxes and themes in '/home/fschoenm/.cache/bat' are not compatible with this version of bat (0.24.0). To solve this, either rebuild the cache (bat cache --build) or remove the custom syntaxes/themes (bat cache --clear).

However, running bat cache --build shows another error:

error: unexpected argument '--build' found

  tip: to pass '--build' as a value, use '-- --build'

Usage: bat <FILE>...

For more information, try '--help'.

bat cache --clear also does not work. There doesn't seem to be a subcommand cache.

What happens?

It doesn't work, no idea why.

What did you expect to happen instead?

No idea what is even the problem. Why cannot bat clear its own cache if it needs to with a new version?

How did you install bat?

Cargo


bat version and environment

0.24.0 on Ubuntu 23.04

Software version

bat 0.24.0

Operating system

Linux 6.2.0-34-generic

Command-line

bat --diagnostic

Environment variables

SHELL=/usr/bin/zsh
PAGER=less
LESS=-R
LANG=en_US.UTF-8
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_PAGING=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=<not set>
NO_COLOR=<not set>
MANPAGER='sh -c '\''col -bx | bat -l man -p'\'''

System Config file

Could not read contents of '/etc/bat/config': No such file or directory (os error 2).

Config file

# This is `bat`s configuration file. Each line either contains a comment or
# a command-line option that you want to pass to `bat` by default. You can
# run `bat --help` to get a list of all possible configuration options.

# Specify desired highlighting theme (e.g. "TwoDark"). Run `bat --list-themes`
# for a list of all available themes
--theme="Catppuccin-macchiato"

# Enable this to use italic text on the terminal. This is not supported on all
# terminal emulators (like tmux, by default):
#--italic-text=always

# Uncomment the following line to disable automatic paging:
#--paging=never

# Uncomment the following line if you are using less version >= 551 and want to
# enable mouse scrolling support in `bat` when running inside tmux. This might
# disable text selection, unless you press shift.
#--pager="less --RAW-CONTROL-CHARS --quit-if-one-screen --mouse"

# Syntax mappings: map a certain filename pattern to a language.
#   Example 1: use the C++ syntax for .ino files
#   Example 2: Use ".gitignore"-style highlighting for ".ignore" files
#--map-syntax "*.ino:C++"
#--map-syntax ".ignore:Git Ignore"

--tabs 4

Custom assets metadata

---
bat_version: 0.23.0
creation_time:
  secs_since_epoch: 1680189409
  nanos_since_epoch: 931383380

Custom assets

  • metadata.yaml, 101 bytes
  • syntaxes.bin, 908131 bytes
  • themes.bin, 46118 bytes

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-linux-gnu

Less version

> less --version
less 590 (GNU regular expressions)
Copyright (C) 1984-2021  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less

fschoenm avatar Oct 16 '23 09:10 fschoenm

I was running the above in tmux. When running without tmux, everything works. No idea why, so maybe you can find it out. I edited the bug report above accordingly :)

fschoenm avatar Oct 16 '23 10:10 fschoenm

No idea what is even the problem. Why cannot bat clear its own cache if it needs to with a new version?

We have an issue tracking this :) https://github.com/sharkdp/bat/issues/2085

I have never used tmux, so forgive this wild guess... Is the bat run from within tmux the same version as the bat run from outside tmux?

keith-hall avatar Oct 19 '23 19:10 keith-hall

Yeah pretty sure it was the same.

fschoenm avatar Oct 26 '23 16:10 fschoenm

Is there any chance you have a file named cache in the directory you were executing the command from while within tmux? If there is, bat will disable the cache subcommand so it can print the file named cache.

image

eth-p avatar Feb 08 '24 05:02 eth-p

any chance you have a file named cache in the directory you were executing the command from

That's probably it. I know it's a terrible UX. We should have never introduced the cache subcommand. But I'm not sure if we will get rid of it now. Closing for now.

sharkdp avatar Feb 08 '24 07:02 sharkdp