Skip to content

setup.bash silently fails on conda/pixi prefixes: _local_setup_util_sh.py not found in chained prefix #734

Description

@antrom99

Environment

  • OS: macOS Sequoia (Apple Silicon, osx-arm64)
  • Shell: zsh
  • ROS 2 Humble via RoboStack + Pixi
  • Python: 3.12 (.pixi/envs/humble/bin/python3.12)
  • colcon-core: latest

Steps to Reproduce

  1. Set up a ROS 2 workspace using RoboStack via Pixi (conda-based environment)
  2. Run colcon build --packages-up-to <package>
  3. Run source install/setup.bash

Actual Behavior

The command silently exits without error code, but the environment is not sourced correctly. With tracing enabled, the failure is:

/path/to/.pixi/envs/humble/bin/python3.12: \
  can't open file '/path/to/.pixi/envs/humble/_local_setup_util_sh.py': \
  [Errno 2] No such file or directory

Expected Behavior

setup.bash should source correctly, or emit a clear error when a chained prefix does not contain _local_setup_util_sh.py.

Root Cause

install/setup.bash chains two prefixes (lines 22–26):

  1. .pixi/envs/humble — the conda/RoboStack ROS 2 base prefix
  2. install/ — the colcon workspace prefix

For each prefix, local_setup.bash invokes:

$_colcon_python_executable \
  "$_colcon_prefix_bash_COLCON_CURRENT_PREFIX/_local_setup_util_sh.py" \
  sh bash

colcon generates _local_setup_util_sh.py only in install/. When processing the first chained prefix (.pixi/envs/humble), Python looks for the file there — but it does not exist because that prefix was installed via conda/pixi, not colcon. The failure is silent because the exit code is swallowed.

Workaround

ln -sf install/_local_setup_util_sh.py .pixi/envs/humble/_local_setup_util_sh.py
ln -sf install/_local_setup_util_ps1.py .pixi/envs/humble/_local_setup_util_ps1.py
source install/setup.bash

Proposed Fix

Add a guard in local_setup.bash before invoking Python, so non-colcon prefixes are skipped gracefully:

if [ -f "$_colcon_prefix_bash_COLCON_CURRENT_PREFIX/_local_setup_util_sh.py" ]; then
  _colcon_ordered_commands="$($_colcon_python_executable \
    "$_colcon_prefix_bash_COLCON_CURRENT_PREFIX/_local_setup_util_sh.py" sh bash)"
fi

Related

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions