question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autocomplete fails while using zsh.

See original GitHub issue

Bug report

Required Info:

  • Operating System:
    • Ubuntu 18.04
  • Installation type:
    • binaries
  • Version or commit hash:
    • Dashing / Eloquent
  • DDS implementation:
    • ALL
  • Client library (if applicable):
    • N/A

Steps to reproduce issue

I use zsh as my shell, but I find some problems while using <tab> to autocomplete.

  • While I type ros2 run <tab>, it works well.
  • However when I type ros2 run d<tab>, it can’t show the packages which starts with ‘d’.

Additional information

After some debugging, I find that the behavior is related to argcomplete library in Python 3. If I remove the library rm -rf ~/.local/lib/python3.6/site-packages/argcomplete*, zsh works well again. I’m not pretty sure what the root cause is. Maybe argcomplete library does not support zsh well.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:26 (9 by maintainers)

github_iconTop GitHub Comments

16reactions
chenjunnncommented, Mar 3, 2022

Having the same issue with Zsh and ROS2 Galactic too.

But I found a solution in https://kislyuk.github.io/argcomplete/#zsh-support

By adding these lines to .zshrc the argcompletion is succesfully enabled.

# argcomplete for ros2 & colcon
eval "$(register-python-argcomplete3 ros2)"
eval "$(register-python-argcomplete3 colcon)"

(Thanks to https://github.com/ros2/ros2cli/issues/534#issuecomment-957905035, I removed the unnessecary autoload -U bashcompinit \ bashcompinit)

image

5reactions
frankkusterscommented, Dec 8, 2021

Instead of running eval "$(register-python-argcomplete3 ros2)" every time after sourcing setup.zsh, I made a modification in /opt/ros/galactic/share/rosidl_cli/environment/rosidl-argcomplete.zsh. I removed/commented the line:

autoload -U +X compinit && compinit

Then ros2 tab completion works. This has to do with compinit being called too many times (see also https://stackoverflow.com/questions/67136714/how-to-properly-call-compinit-and-bashcompinit-in-zsh ).

I’m not sure what a final fix should be, especially since tab completion for colcon still doesn’t work with this change (the eval "$(register-python-argcomplete3 colcon)" is still needed for that).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autocompletion not working for pass password manager in ...
If completions in zsh are not working then the pass.zsh-completion file is not in the right place or on the (right) path.
Read more >
shell - Zsh tab-completion not working - Stack Overflow
Hello, after switching from Bash to Zsh on macOS Catalina, Tab completion stopped working for me. Apparently it is working in directories where ......
Read more >
Pass autocomplete only works directly after installing oh-my-zsh
If I close and re-open the terminal, auto-complete no longer works. I'm running MacOS BigSur M1. I'm using the Unix Pass manager, which...
Read more >
2055162 – Autocompletion broken in zsh-5.8.1
I guess this was caused by updating the zsh package from 5.8 to 5.8.1 while zsh was running. The following command (or opening...
Read more >
zsh auto-completion - Kubernetes
After reloading your shell, kubectl autocompletion should be working. If you get an error like 2: command not found: compdef , then add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found