You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To take advantage of this feature, a package needs to install autocompletion files in one of these directories depending on the user's shell:
share/bash-completion/completions
share/zsh/site-functions
share/fish/vendor_completions.d
I tested this with both Bash and Zsh on macOS, using the attached scripts (unzip in the root of your pixi workspace) and it's working great. What's missing is just RoboStack installing these files automatically as part of the distribution.
Is this the correct repo to discuss how to possibly get this merged? We encountered this as part of a university course on ROS we are teaching, so we'd really benefit from a fix. I can send a pull request after we define how you'd like to approach this.
Thanks to Pixi we've been able to migrate from a cumbersome VM that we used to prepare and distribute to students, to a single set of instructions that they can follow themselves to setup a native environment in macOS / Ubuntu / Windows. It's a great improvement!
Reacted by Tobias Fischer, Ruben Arts, Silvio Traversaro and Wolf Vollprecht
That's great to hear @EliaCereda, exactly what we are designing pixi for!
The quickest way would be to add these scripts to the colcon and the package the ros2 cli comes from. It's also pretty normal to create a separate package like colcon-completions which you would version similarly to colcon. This way, a user can decide to install the completions.
The extra package has my preference but might not be worth the work as these environments are huge anyway.
I am bit confused on how this works anyhow. I have a bit of experience with feedstock providing autocomplete scripts (see https://github.com/conda-forge/yarp-feedstock, even if it is not clear how that works from the feedstock as the installation is handled by CMake), but I am not sure how the proposed one works.
Just to understand, what is the reason not to just add the autocomplete script in the main package? The increase time spent in the activation scripts, or people not wanting autocomplete for some reason?
By looking at the installed files ( https://conda-metadata-app.streamlit.app/?q=conda-forge%2Fnoarch%2Fcolcon-argcomplete-0.3.3-pyhd8ed1ab_1.conda ) I guess it does not work out of the box, we probably need to install some scripts in share/bash-completion/completions and share/zsh/site-functions that call the existing scripts, and verify if they do not conflict with then the same script is called as part of the colcon workspace activation.
There should be a cleaner way of doing this. Installing ROS from Ubuntu APT does indeed install autocompletion by default, but I could not find how that is setup exactly
There should be a cleaner way of doing this. Installing ROS from Ubuntu APT does indeed install autocompletion by default, but I could not find how that is setup exactly
Is ROS autocompletion on by default, or just after sourcing the setup.sh ? I would be surprised if it works even without sourcing the setup.sh of the ROS installation. What about colcon instead?
No, it's enabled by the setup.sh. This doesn't work in Pixi because I think it executes the setup.sh in a sub-shell which collects what environment variables are set and then only sets those in the actual user shell. This is true for both the setup.sh of the ROS distribution and for any setup.sh that are added as activation scripts in the pixi.toml.
When launching a pixi shell, Pixi sources the setup.sh with its custom system that preserves environment variables but not other shell customization (such as autocompletion). This breaks the assumption of ROS packages that they'll have their activation scripts sourced directly from the user shell.
Even if I source the setup.sh inside a pixi shell manually, it doesn't seem to enable the autocompletion correctly. Running eval "$(register-python-argcomplete ros2)" directly works instead.
The latter might be the same problem from the StackOverflow answer I linked above (I haven't investigated further)
The former however appears to me as a fundamental problem in the way Pixi handles activation scripts. Do you have ideas for how ROS should fit in your design?
Thanks for the in-detail analysis. From my point of view, the simple solution for this is:
Modify/patch the colcon-argcomplete conda-forge recipe to install its argcomplete script in the folders supported by pixi. In this case, also just copying the files in the build.sh script is doable.
Modify/patch the ros-humble-ros2cli robostack package to install its argcomplete script in the folders supported by pixi. In this case, modifying the build.sh is more tricky as that is generated by vinca, an easier option may be to do a simple patch to the CMakeLists.txt of ros2cli to install them in the correct place.
My only doubt is for @ruben-arts , i.e. quoting my earlier comment:
Just to understand, what is the reason not to just add the autocomplete script in the main package? The increase time spent in the activation scripts, or people not wanting autocomplete for some reason?
Unless there is a compelling reason do to that, I would avoid the complexity of adding an output for the recipe just for the autocomplete script, that especially for robostack packages is really far from trivial.
to simply be eval "$(register-python-argcomplete colcon)" and eval "$(register-python-argcomplete ros2). As far as I can see, register-python-argcomplete3 was never packaged in conda-forge, so the only case in which register-python-argcomplete3 exists is on old Ubuntu distros, and preferring register-python-argcomplete3 over register-python-argcomplete will mean that the apt python is used in place of the conda/pixi python, resulting in wrong autocompletes.
I went ahead and tried to patch ros2cli and rosidl_cli to install their autocompletion scripts in the proper locations. Is anything else needed for these patches to be picked up by the build system?
I went ahead and tried to patch ros2cli and rosidl_cli to install their autocompletion scripts in the proper locations. Is anything else needed for these patches to be picked up by the build system?
Yes, but I will comment in the PR, thanks for looking into this!
I tried briefly yesterday but it didn't seem to work, I still need to investigate. ros2cli is installing the files but autocompletion is not activated, while rosidl-cli doesn't install the file at all.
What I don't exactly understand either is that when I pixi shell then eval "$(register-python-argcomplete colcon); eval "$(register-python-argcomplete ros2)", then it works fine. However I cannot automatically source those commands in my pixi.toml like so:
What I don't exactly understand either is that when I pixi shell then eval "$(register-python-argcomplete colcon); eval "$(register-python-argcomplete ros2)", then it works fine. However I cannot automatically source those commands in my pixi.toml like so:
Fixed for ros2 (and rosidl) in the RoboStack monorepo, RoboStack/robostack, where all ROS 2 distributions are now built by RoboStack/robostack#70: the bash and zsh completions are now installed where the shells pick them up automatically, including in pixi environments. For humble, it ships with the rebuild in RoboStack/robostack#62, so it reaches users once that's merged and uploaded; the published ros2cli doesn't have it yet. colcon completion, also asked about here, comes from conda-forge's colcon-argcomplete, not RoboStack.
Activity
Tobias-Fischer commentedon Mar 27, 2025
A question for @wolfv I think how to best achieve this
Tobias-Fischer commentedon Mar 27, 2025
PS: which uni / course do you teach?
traversaro commentedon Mar 27, 2025
I guess also @ruben-arts may be interested.
EliaCereda commentedon Mar 27, 2025
It's Robotics in the Master in AI at USI (Lugano, Switzerland), https://search.usi.ch/en/courses/35270726/robotics
Thanks to Pixi we've been able to migrate from a cumbersome VM that we used to prepare and distribute to students, to a single set of instructions that they can follow themselves to setup a native environment in macOS / Ubuntu / Windows. It's a great improvement!
ruben-arts commentedon Mar 27, 2025
That's great to hear @EliaCereda, exactly what we are designing pixi for!
The quickest way would be to add these scripts to the
colconand the package theros2cli comes from. It's also pretty normal to create a separate package likecolcon-completionswhich you would version similarly tocolcon. This way, a user can decide to install the completions.The extra package has my preference but might not be worth the work as these environments are huge anyway.
traversaro commentedon Mar 27, 2025
I am bit confused on how this works anyhow. I have a bit of experience with feedstock providing autocomplete scripts (see https://github.com/conda-forge/yarp-feedstock, even if it is not clear how that works from the feedstock as the installation is handled by CMake), but I am not sure how the proposed one works.
In particular if the autocomplete script is:
who installs the
register-python-argcompleteexecutable? Python? In that case, for colcon we can add it in https://github.com/conda-forge/colcon-core-feedstock/blob/main/recipe/meta.yaml, that already installs the colcon entry point, but to follow @ruben-arts suggestions we would need to turn that in a multi-output recipe. @ruben-arts do you have any example feedstock implementing that?Just to understand, what is the reason not to just add the autocomplete script in the main package? The increase time spent in the activation scripts, or people not wanting autocomplete for some reason?
traversaro commentedon Mar 27, 2025
On the colcon side I found https://github.com/colcon/colcon-argcomplete, that is packaged in https://github.com/conda-forge/colcon-argcomplete-feedstock, have you tried if just installing
colcon-argcompleteworks fine? (in that case, a possible action is just to document that this needs to be installed for autocompletion).traversaro commentedon Mar 27, 2025
By looking at the installed files ( https://conda-metadata-app.streamlit.app/?q=conda-forge%2Fnoarch%2Fcolcon-argcomplete-0.3.3-pyhd8ed1ab_1.conda ) I guess it does not work out of the box, we probably need to install some scripts in
share/bash-completion/completionsandshare/zsh/site-functionsthat call the existing scripts, and verify if they do not conflict with then the same script is called as part of the colcon workspace activation.traversaro commentedon Mar 27, 2025
See also colcon/colcon-argcomplete#41 and colcon/colcon-argcomplete#43 .
EliaCereda commentedon Mar 27, 2025
I haven't looked deep into how it works, the
register-python-argcompletecommands are from this answer: https://robotics.stackexchange.com/a/100987There should be a cleaner way of doing this. Installing ROS from Ubuntu APT does indeed install autocompletion by default, but I could not find how that is setup exactly
traversaro commentedon Mar 27, 2025
Is ROS autocompletion on by default, or just after sourcing the
setup.sh? I would be surprised if it works even without sourcing thesetup.shof the ROS installation. What about colcon instead?EliaCereda commentedon Mar 27, 2025
No, it's enabled by the
setup.sh. This doesn't work in Pixi because I think it executes thesetup.shin a sub-shell which collects what environment variables are set and then only sets those in the actual user shell. This is true for both thesetup.shof the ROS distribution and for anysetup.shthat are added as activation scripts in thepixi.toml.traversaro commentedon Mar 27, 2025
Ah, hence the need for actually installing the scripts in
share/bash-completion/completions.EliaCereda commentedon Mar 31, 2025
I just spent a bit more time looking at what ROS actually does to enable autocompletion.
The sequence for a normal ROS installation is:
setup.shfor a given workspacesetup.shrunssource local_setup.shfor the current workspace and all underlying workspaceslocal_setup.shruns_local_setup_util.pyto collect the activation commands of all installed packagesshare/<package name/package.dsvif it exists, otherwise default toshare/<package name/local_setup.{sh,bash,zsh}local_setup.shevals the output of_local_setup_util.pyto run the commands inside the user's shellHere's the output I get from
_local_setup_util.pyon my system:_ament_prefix_sh_source_script is defined in
local_setup.sh, it just sources the file if it exists, and ignores it otherwise.Out of those commands,
ros2-argcomplete.shdoesn't do anything except callingregister-python-argcomplete:So it seems to me we have two problems here:
setup.shwith its custom system that preserves environment variables but not other shell customization (such as autocompletion). This breaks the assumption of ROS packages that they'll have their activation scripts sourced directly from the user shell.setup.shinside a pixi shell manually, it doesn't seem to enable the autocompletion correctly. Runningeval "$(register-python-argcomplete ros2)"directly works instead.The latter might be the same problem from the StackOverflow answer I linked above (I haven't investigated further)
The former however appears to me as a fundamental problem in the way Pixi handles activation scripts. Do you have ideas for how ROS should fit in your design?
traversaro commentedon Mar 31, 2025
Thanks for the in-detail analysis. From my point of view, the simple solution for this is:
colcon-argcompleteconda-forge recipe to install its argcomplete script in the folders supported by pixi. In this case, also just copying the files in thebuild.shscript is doable.ros-humble-ros2clirobostack package to install its argcomplete script in the folders supported by pixi. In this case, modifying thebuild.shis more tricky as that is generated by vinca, an easier option may be to do a simple patch to the CMakeLists.txt ofros2clito install them in the correct place.My only doubt is for @ruben-arts , i.e. quoting my earlier comment:
Unless there is a compelling reason do to that, I would avoid the complexity of adding an output for the recipe just for the autocomplete script, that especially for robostack packages is really far from trivial.
wolfv commentedon Mar 31, 2025
I think it's fine to add the autocompletion script to the main output.
They will only be sourced when running
pixi shell, sopixi runwould not have a performance hit.And for
pixi shellit's a nice-to-have feature in my opinion :)traversaro commentedon Mar 31, 2025
Ah, one additional note, probably we may want to patch:
to simply be
eval "$(register-python-argcomplete colcon)"andeval "$(register-python-argcomplete ros2). As far as I can see,register-python-argcomplete3was never packaged in conda-forge, so the only case in whichregister-python-argcomplete3exists is on old Ubuntu distros, and preferringregister-python-argcomplete3overregister-python-argcompletewill mean that the apt python is used in place of the conda/pixi python, resulting in wrong autocompletes.traversaro commentedon Mar 31, 2025
So we also get rid of the need to have different scripts of
zshandbash.EliaCereda commentedon Mar 31, 2025
I went ahead and tried to patch
ros2cliandrosidl_clito install their autocompletion scripts in the proper locations. Is anything else needed for these patches to be picked up by the build system?traversaro commentedon Mar 31, 2025
Yes, but I will comment in the PR, thanks for looking into this!
traversaro commentedon Apr 10, 2025
This should have been fixed by prefix-dev/pixi#3506, @EliaCereda did you checked if everything works as expected? Thanks!
EliaCereda commentedon Apr 10, 2025
I tried briefly yesterday but it didn't seem to work, I still need to investigate.
ros2cliis installing the files but autocompletion is not activated, whilerosidl-clidoesn't install the file at all.Do you have any idea why for the latter?
traversaro commentedon Apr 10, 2025
This is interesting. Can you report a
conda listorpixi list? So we verify that indeed the build number of the packages is indeed_9(the version that should include our patches), see https://anaconda.org/robostack-humble/ros-humble-ros2cli/files and https://anaconda.org/robostack-humble/ros-humble-rosidl-cli/files . You can even enforce this in your pixi file if you want, with:wolfv commentedon Apr 10, 2025
Please let me know if there is an issue in the pixi side of things :)
2lian commentedon Nov 22, 2025
Hi there!
Is this supposed to be working? because it is not working for me despite using the latest versions of the packages.
What I don't exactly understand either is that when I
pixi shelltheneval "$(register-python-argcomplete colcon); eval "$(register-python-argcomplete ros2)", then it works fine. However I cannot automatically source those commands in mypixi.tomllike so:kyrie2to11 commentedon Jan 29, 2026
Same problem—any elegant workaround these days? Thanks!
jarvis@ThinkPad-P1-Gen-6:~/projects/iRail-Truck/ros2bookcode$ pixi --version pixi 0.63.2Tobias-Fischer commentedon Oct 18, 2026
Fixed for
ros2(androsidl) in the RoboStack monorepo, RoboStack/robostack, where all ROS 2 distributions are now built by RoboStack/robostack#70: the bash and zsh completions are now installed where the shells pick them up automatically, including in pixi environments. For humble, it ships with the rebuild in RoboStack/robostack#62, so it reaches users once that's merged and uploaded; the publishedros2clidoesn't have it yet.colconcompletion, also asked about here, comes from conda-forge'scolcon-argcomplete, not RoboStack.🤖 Claude (AI assistant), on behalf of @Tobias-Fischer