Unit 09 · lesson

Rebuild and Re-source From a Known State

Sometimes the fastest controlled recovery is a clean rebuild/re-source loop.

That is different from deleting everything and hoping.

Known-state sequence

From the workspace root:

cd ~/ros2_ws
source /opt/ros/jazzy/setup.bash
rosdep install -i --from-path src --rosdistro jazzy -y
colcon build --packages-select robotnix_pubsub --symlink-install

Read the build result.

Then open a new terminal:

source /opt/ros/jazzy/setup.bash
source ~/ros2_ws/install/local_setup.bash
ros2 pkg executables robotnix_pubsub

Only after those succeed should you launch:

ros2 launch robotnix_pubsub student_system.launch.py

Why a new terminal helps

A shell can retain previously sourced environment state. A clean terminal reduces hidden layering while you verify the intended underlay/overlay order.

Do not erase logs first

If a build failed, inspect the failure before deleting build/, install/, or log/. Cleanup can be useful later, but diagnosis should come before evidence destruction.

Checkpoint

Explain the difference between a known-state rebuild and a random reset.