tmux-copy-toolkit icon indicating copy to clipboard operation
tmux-copy-toolkit copied to clipboard

bug: fails to run when `LANG=ja_JP.UTF-8`

Open pysan3 opened this issue 3 years ago • 0 comments

Hi @CrispyConductor,

Thanks for the awesome plugin :)

I bumped into a bug running this plugin when I set the default language of the shell to Japanese with LANG=ja_JP.UTF-8.

Traceback

$ python3 /home/user/.local/share/tmux/plugins/tmux-copy-toolkit/copytk.py easycopy --search-nkeys 1
Traceback (most recent call last):
  File "/home/user/.local/share/tmux/plugins/tmux-copy-toolkit/copytk.py", line 1356, in <module>
    run_wrapper(args.action, args)
  File "/home/user/.local/share/tmux/plugins/tmux-copy-toolkit/copytk.py", line 1293, in run_wrapper
    pane = get_pane_info(args.t)
  File "/home/user/.local/share/tmux/plugins/tmux-copy-toolkit/copytk.py", line 253, in get_pane_info
    r = runtmux(args, one=True).split(' ')
  File "/home/user/.local/share/tmux/plugins/tmux-copy-toolkit/copytk.py", line 88, in runtmux
    with subprocess.Popen(
  File "/home/user/.local/share/pyenv/versions/3.8.5/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/user/.local/share/pyenv/versions/3.8.5/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/tmux です'

The output of command -V command is different in the Japanese version.

$ LANG=ja_JP.UTF-8 command -V tmux
tmux は /usr/bin/tmux です
$ LANG=en_US.UTF-8 command -V tmux
tmux is /usr/bin/tmux

Possible Fix

Specifying LANG fixed the problem in my case. However, I was not confident enough to send a PR whether this solution works on every environment...

  # copytk.py line 25
  def find_command_path(c):
-    cmd = 'command -V ' + c
+    cmd = 'LANG=en_US.UTF-8 command -V ' + c
     f = os.popen(cmd)

Hope this helps.

Best, pysan3

pysan3 avatar Mar 13 '22 13:03 pysan3