colcon-bash

0.5.0 · active · verified Fri Apr 17

colcon-bash is an extension for the colcon build system, primarily used in robotics development (e.g., ROS 2). It provides the functionality to generate Bash shell scripts (e.g., `setup.bash`) within colcon workspaces. These scripts are crucial for setting up the environment, allowing users to easily source packages and make their executables and libraries discoverable. The current version is 0.5.0, and it follows the colcon project's release cadence, often coinciding with ROS 2 releases or colcon-core updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how `colcon-bash` integrates with `colcon`. After building a package, `colcon-bash` ensures that `install/setup.bash` is generated. Sourcing this script adds package-specific environment variables and PATH entries, allowing executables like `my_executable` to be run directly.

# Create a colcon workspace
mkdir -p my_colcon_ws/src
cd my_colcon_ws/src

# Create a minimal C++ package (CMake)
mkdir my_pkg
cd my_pkg
cat << EOF > CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(my_pkg NONE)
add_executable(my_executable my_executable.cpp)
EOF
cat << EOF > my_executable.cpp
#include <iostream>

int main() {
    std::cout << "Hello from my_pkg!" << std::endl;
    return 0;
}
EOF
cd .. # back to src

# Build the workspace using colcon (colcon-bash will generate setup.bash)
cd .. # back to my_colcon_ws
# Note: ensure colcon-bash is installed (e.g., pip install colcon-common-extensions)
colcon build --packages-select my_pkg

# Source the generated setup script to make the package discoverable
source install/setup.bash

# Run the executable from the environment
my_executable

view raw JSON →