This project is an example of using the new remote development features of CLion 2018.3 with a Vagrant VM as the remote host. See the 2018.2 branch for using earlier versions of CLion that support remote debugging but not remote builds.
CLion does not have Vagrant support yet, so some modifications to the
standard Vagrant workflow are necessary; see the project Vagrantfile
. The
Vagrant box must be Linux, and it must have rsync and a recent version of
GDB (7.8+). Newer versions of Ubuntu include a compatible version of GDB in
their standard package repos, but CentOS users will have to build a version
from source.
- Clone this project.
2. Start and provision the Vagrant box. Note the connection port and remote project directory in the Vagrant start-up messages.
$ vagrant up
...
==> default: CLion workarounds enabled
==> default: Use port 22000 for CLion remote host connection
==> default: Use /vagrant as the remote deployment directory
Define a Toolchain to configure the build and debug tools for the Vagrant box. Here, a fixed SSH port is used to connect. A static IP can be instead. In either case, the address must be unique on the local machine.
Use the Vagrant private key file for this connection.
Once the Toolchain is configured, hit
Apply
to create it.Define one or more CMake Profiles to configure the build types to use with the Vagrant Toolchain.
When a remote Toolchain is created, CLion will create the corresponding SFTP deployment. CLion does not yet support mounted folders for remote builds, so a Vagrant synced folder cannot be used for the project directory.
The local project is directory is mapped to
/vagrant
on the VM. Here, CLion will manage the remote directory, not Vagrant. Files in the project directory cannot be used during Vagrant provisioning because they will not be synced to the VM at that point.CLion will automatically exclude the local build directory from syncing, but all other exclusions must be manually configured. The local
.vagrant/
directory should be excluded along with any other files that are not needed to build or run the project.
Once the project is properly configured, CLion will sync files to the Vagrant VM and run CMake to build the project model. Run/Debug Configurations will be created for all of the project executables.
CLion can now be used to edit, build, debug, and test the project as if it was on the local machine.
Project binaries built on the remote machine will be available in the local copy of the build directory.
Use YouTrack to report new bugs, find workarounds for existing bugs, and make feature requests. Many remote development bugs are attached to CPP-744.
It will sometimes be necessary to run Tools->CMake->Reload CMake Project
to
force CLion to reconnect to the remote host.
It is possible for the project to get into an inconsistent state that will disrupt file syncing. In some cases, CLion will be unable to sync updated build files from the remote machine to the local machine. In other cases, CLion will stop syncing local source files to the remote machine. If this occurs, try these troubleshooting steps:
- Run
Tools->CMake->Reset Cache and Reload Project
- Run
File->Invalidate Caches / Restart
- Restart the Vagrant VM
- Delete the remote Toolchain configuration and recreate it