0

I'm getting the following error output when trying to start Neovim ($ nvim ...):

bash: _longopt: line 6: syntax error near unexpected token `('
bash: _longopt: line 6: ` --!(no-*)dir*)'
bash: error importing function definition for `_longopt'
bash: _parse_usage: line 16: syntax error near unexpected token `('
bash: _parse_usage: line 16: ` -?(\[)+([a-zA-Z0-9?]))'
bash: error importing function definition for `_parse_usage'
bash: _services: line 5: syntax error near unexpected token `('
bash: _services: line 5: ` COMPREPLY=($(printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions|README)));'

What can I do to resolve this? It worked just a second ago... all that I did was remove a ROS source statement from my bashrc using nvim, and since then it will not work.

steeldriver
  • 143,099
  • 2
    What exactly do you mean by "($ nvim ...)"? The error message is the kind of thing you'd see if bash completion is being invoked with the extglob option unset I think – steeldriver May 27 '25 at 01:13
  • I agree with steeldriver, your issue seems rather related to bash-completion. Your question is a possible duplicate of https://askubuntu.com/questions/1001653/why-am-i-getting-parse-usage-error-on-function-invocation-in-bash. Please check the suggestions listed in this thread. If the problem persists, try to create a new user and run nvim. – Mando Мандо May 28 '25 at 14:03

1 Answers1

0

The errors you’re seeing aren’t Neovim itself crashing—they’re Bash complaining about “broken” function‐definitions in your environment. In other words, when you run nvim, Bash is importing some exported functions (like _longopt, _parse_usage, _services) whose contents now contain unescaped “extended‐glob” patterns (e.g. !(no-*) or ?([a-zA-Z0-9?])) that Bash isn’t set up to parse. Those function bodies probably came from ROS’s setup scripts or some completion file you sourced earlier, and by removing that ROS line, you left behind half‐defined exports that Bash can no longer read.

Try this:

env | grep '^[A-Za-z0-9_]\+=\(\)' \ | cut -d= -f1 \ | xargs -r -n1 unset -f

  • env | grep '^[A-Za-z0-9_]\+=\(\)' finds all “VAR=()” lines in your environment (i.e. exported functions).
  • cut -d= -f1 pulls out just the function names.
  • xargs -r -n1 unset -f unsets each one.