2

I noticed the error this morning, but I don't think I have changed anything last night, so I am very confused right now. Perhaps I updated some utilities on my system and it somehow broke the back compatibility. Basically I got a math: Error: Missing operator error when using tab completion.

Say I type fish, and hit Tab to get the suggestions like fish_config and fish_add_path (here is an asciinema screencast in case you want to see it in action: https://asciinema.org/a/L3xr32eVMGHuCY0Gjr19gFzCu)

[I] ~ $ fishmath: Error: Missing operator
'Wed Dec 31 18:00:00 CST 1969 - 1655913830'
 ^
[I] ~ $ fish_config
fish                                                                               (command)
fish_add_path
fish_breakpoint_prompt
fish_clipboard_copy
…and 29 more rows

The tab completion does work, but the error looks very annoying. Looks like I am trying to evaluate a data string or something. How do I diagnose the bug?


I am on macOS Monterey. Here is my ~/.config/fish/config.fish.

set -px PATH /opt/local/bin /opt/local/sbin
set -px PATH $HOME/.local/bin
set -px PATH $HOME/bin
set -px PATH /Applications/MacPorts/Alacritty.app/Contents/MacOS
set -px PATH $HOME/Foreign/drawterm
set -px PATH $HOME/google-cloud-sdk/bin

set -x XDG_CONFIG_HOME $HOME/.config
set -x PIPENV_VENV_IN_PROJECT 1
set -x PLAN9 /usr/local/plan9

set -px PATH $PLAN9/bin

if test -e $HOME/.config/fish/sensitive.fish
    source $HOME/.config/fish/sensitive.fish
end

if status is-interactive
    # Commands to run in interactive sessions can go here
    alias vi='/opt/local/bin/nvim'
    set -gx EDITOR /opt/local/bin/nvim
    source /opt/local/share/fzf/shell/key-bindings.fish
end

set -g fish_key_bindings fish_hybrid_key_bindings

alias matlab='/Applications/MATLAB_R2021b.app/bin/matlab -nodisplay'

zoxide init fish | source

direnv hook fish | source

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/qys/google-cloud-sdk/path.fish.inc' ]; . '/Users/qys/google-cloud-sdk/path.fish.inc'; end
3
  • Please edit your question and tell us what operating system you are using. If possible, also try logging in as a different user and checking if the error appears there too, otherwise we can know it is a problem specific to your normal user.
    – terdon
    Jul 4, 2022 at 16:30
  • @terdon I have edited the question. I am on macOS, and I am effectively the only user on the system.
    – nalzok
    Jul 4, 2022 at 18:16
  • 1
    Thanks, and double thanks for taking the time to post your solution!
    – terdon
    Jul 4, 2022 at 18:39

2 Answers 2

4

The error goes away after I remove the line set -px PATH $PLAN9/bin. I guess it was because I accidentally shadowed some system utilities with its counterpart in Plan 9 from User Space.

Another workaround is to use set -ax PATH $PLAN9/bin instead. By using -a, the directory $PLAN9/bin is appended to $PATH (as opposed to prepended when using -p), so that the commands already present in $PATH takes precedence over the Plan 9 ones.

1

What happens here is that fish tries to complete commands, and it tries to add descriptions to them by calling apropos.

On macOS, this is super slow because Apple's sandboxing breaks the whatis database.

So, fish adds its own caching instead, and this cache is updated once a week.

Only to check that date, it runs:

set age (math (date +%s) - (/usr/bin/stat -f %m $whatis))

Giving date the +%s format specifier to get just the unix epoch.

You had overridden date with the (as is typical) ultra-minimalist Plan 9 version, which doesn't take a format argument, so it ends up printing a full date, which makes the math expression malformed.

In general, fish assumes a reasonably standard unix userspace, and so prepending Plan 9 tools (which aren't) is a bad idea.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .