Skip to content

Fix ros2cli + rosidl_cli auto-completion#206

Draft
rhaschke wants to merge 3 commits into
RoboStack:mainfrom
rhaschke:main
Draft

Fix ros2cli + rosidl_cli auto-completion#206
rhaschke wants to merge 3 commits into
RoboStack:mainfrom
rhaschke:main

Conversation

@rhaschke

Copy link
Copy Markdown

@rhaschke rhaschke marked this pull request as draft April 18, 2026 09:02
@rhaschke

rhaschke commented Apr 18, 2026

Copy link
Copy Markdown
Author

The backport from ros-humble doesn't actually work for me 😞. pixi's configured shell-hook is simply wrong:

$ pixi shell-hook -e jazzy
...
source /vol/robostack/.pixi/envs/jazzy/share/bash-completion/completions/*
...

The source command just considers the first file argument. It cannot be used to source multiple files at once!

However, I don't understand, why sourcing $CONDA_PREFIX/setup.sh in /vol/robostack/.pixi/envs/jazzy/etc/conda/activate.d/ros-jazzy-ros-workspace_activate.sh doesn't activate completion in first place. Enabling tracing (export AMENT_TRACE_SETUP_FILES=1) reveals that the corresponding command is correctly created (and evaluated):

# Package: ros2cli
# /vol/robostack/.pixi/envs/jazzy/share/ros2cli/package.dsv
AMENT_CURRENT_PREFIX="/vol/robostack/.pixi/envs/jazzy" _ament_prefix_sh_source_script "/vol/robostack/.pixi/envs/jazzy/share/ros2cli/environment/ros2-argcomplete.bash"

Is it possible that pixi's activation mechanism has changed and executes the activation scripts within a subshell? I'm using pixi 0.67.0.

@Tobias-Fischer

Copy link
Copy Markdown
Contributor

Cc @wolfv @ruben-arts

@rhaschke

rhaschke commented Apr 18, 2026

Copy link
Copy Markdown
Author

Manually sourcing .pixi/envs/jazzy/etc/conda/activate.d/ros-jazzy-ros-workspace_activate.sh enables completion as expected. So, this indeed seems to be a pixi issue.
eval "$(pixi shell-hook -e jazzy)" works as well.

In any case, the following change needs to be applied to that file:

- source $CONDA_PREFIX/setup.sh
+ source $CONDA_PREFIX/setup.bash

@rhaschke

Copy link
Copy Markdown
Author

Is this issue related: prefix-dev/pixi#2330?

@Tobias-Fischer

Copy link
Copy Markdown
Contributor

Hi @wolfv @ruben-arts @baszalmstra - you probably understand this better than me, could you please take a look?

@Tobias-Fischer

Copy link
Copy Markdown
Contributor

Quick ping @wolfv @ruben-arts @baszalmstra @traversaro

@zimmerman-pliant

zimmerman-pliant commented Jun 18, 2026

Copy link
Copy Markdown

A workaround for this in the interim seems to be the following:

sudo apt install python3-argcomplete

then in .bashrc

eval "$(register-python-argcomplete ros2)"
eval "$(register-python-argcomplete colcon)"

Would love this to work out of the box on Robostack installations, however.

@rhaschke

Copy link
Copy Markdown
Author

A workaround for this in the interim seems to be ...

Easier than manually registering all relevant programs, is to source:
.pixi/envs/<distro>/etc/conda/activate.d/ros-<distro>-ros-workspace_activate.sh

as suggested in #206 (comment)

@traversaro

traversaro commented Jun 19, 2026

Copy link
Copy Markdown
Member

Manually sourcing .pixi/envs/jazzy/etc/conda/activate.d/ros-jazzy-ros-workspace_activate.sh enables completion as expected. So, this indeed seems to be a pixi issue. eval "$(pixi shell-hook -e jazzy)" works as well.

In any case, the following change needs to be applied to that file:

- source $CONDA_PREFIX/setup.sh
+ source $CONDA_PREFIX/setup.bash

I think the problem is pixi is not actually executing the scripts in the shell, it executes the scripts, capture how they modified the environment, and then set the modification in the shell. So the autocomplete do not work, see prefix-dev/pixi#2366 . To be honest, I am not sure if this we can fix on the robostack side, or we need to fix something on pixi. fyi @ruben-arts @wolfv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

completion for ros2cli not working

4 participants