Almost Devcontainer in CLion
Overview
Devcontainer plugin in CLion is not as good as in VSCode. It's almost entirely broken. An alternative is to use Docker Compose to run the container and configure CLion to use it as a remote toolchain.
Prerequisites
- Docker
- CLion + extra Docker plugin
Getting Started
Open repository in CLion.
Run containers with Docker Compose.
bashcd .devcontainer/ docker-compose up -d
cd .devcontainer/ docker-compose up -d
Setup container Unlike to VSCode devcontainer support, CLion will not setup container automatically. You have to do it manually.
- Shell into workspace container.
bashdocker compose exec workspace bash
docker compose exec workspace bash
- Setup ROS dependencies.
bashcd /home/ws && sudo apt update && rosdep update && make custom-deps deps
cd /home/ws && sudo apt update && rosdep update && make custom-deps deps
Configure CLion.
- Open
Settings
->Build, Execution, Deployment
->Toolchains
. - Add new toolchain with remote host
localhost
, port2222
and remote useropenmower
authenticated with passwordopenmower
. - Inside workspace container run a command that retrieves ROS workspace env vars:
bashdocker compose exec workspace /home/ws/envs.sh
docker compose exec workspace /home/ws/envs.sh
- In
Settings
->Build, Execution, Deployment
->CMake
pick your new toolchain and fill inEnvironment
with env vars from previous step.
- Open
Load targets
- Open
CMakeLists.txt
and clickLoad CMake Project
. - Make sure every target you want to build is configured with your new toolchain and has the same env vars as for CMake.
- Open
Enjoy your development environment.
TIP
Please see detailed information on containers.