Overview
Thepost-start.sh script runs every time the development container starts. It verifies the workspace, builds it if necessary, and provides quick start instructions.
Location: .devcontainer/post-start.sh
Execution: Automatically run by postStartCommand in devcontainer.json
Runtime:
- First run: 2-3 minutes (full build)
- Subsequent runs: < 5 seconds (skip build)
Script structure
Initialization
Environment setup
Filesystem synchronization
Package verification
- Try to find packages using
findcommand - If no packages found, try
lsmethod (Windows compatibility) - Report count
- Exit with error if no packages found
find, so ls provides a fallback.
Build status check
- Check if
install/setup.bashexists - Source it if it does
- Verify TurtleBot3 packages are available
- If yes: Skip build and exit successfully
- If no: Continue to build phase
Workspace build
- Display estimated build time
- Clean previous build artifacts
- Run colcon build with optimized settings
- Check exit status
- Exit with error if build fails
--symlink-install: Create symlinks instead of copying files (faster iteration)--cmake-args -DCMAKE_BUILD_TYPE=Release: Optimized release build
Build verification
- Source the newly built workspace
- List all TurtleBot3 packages
- Provides visual confirmation of what was built
- turtlebot3
- turtlebot3_bringup
- turtlebot3_cartographer
- turtlebot3_description
- turtlebot3_fake_node
- turtlebot3_gazebo
- turtlebot3_navigation2
- turtlebot3_node
- turtlebot3_teleop
- turtlebot3_example (if available)
Success message
Execution flow
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success (workspace ready) |
| 1 | Error (no packages or build failed) |
Build optimization
Symlink install
- Faster development iteration
- No need to rebuild when editing Python scripts or launch files
- Reduces disk space usage
install/, creates symlinks to src/
Release build
- Optimized code generation
- Better runtime performance
- Smaller binary sizes
Common scenarios
First container start
Container restart
After modifying source code
Container restart will skip the build. To rebuild:Troubleshooting
No packages found error
Build failed error
Build succeeds but packages not found
Cause: Workspace not sourced Solution:Long build times on subsequent runs
Cause: Clean build is triggered instead of incremental Solution: The script only does a clean build on first run. For manual builds, avoidrm -rf build install log and just run:
Performance considerations
Build time factors
| Factor | Impact |
|---|---|
| Number of CPU cores | Higher = faster |
| Disk I/O speed | SSD much faster than HDD |
| Available RAM | Low RAM = slower builds |
| Network mount | Local disk faster than network |
Parallel builds
Colcon automatically uses parallel builds. To limit:Integration with development workflow
- Container start: post-start.sh ensures workspace is ready
- Development: Edit code in
src/ - Build: Use
cbalias - Source: Use
sbalias - Test: Run your nodes/launch files
- Iterate: Repeat steps 2-5