CLion: is `Re-Init` the same as `pio init --ide clion`? When to use it?

According to the docs: CLion — PlatformIO latest documentation

Please note that “PlatformIO for CLion” plugin does not update automatically CLion configuration. There is a feature request CLion #CPP-18367: Follow platformio.ini changes and update the project.

So if I understand correctly, I should run it with every change to my platformio.ini [1]?
Any other situations I should run it [2]? Like, if I added a new lib subdir, or something?

a.) Update CLion configuration: “Tools > PlatformIO > Re-Init”
b.) pio init --ide clion

Do those two do exactly the same, or is there any difference [3]? If there is, what is it, and when should I run which?

Actually, the final question would be, what does it exactly do [4]? I’ve tried to look for the init command in the docs, but I don’t see the init entry: CLI Guide — PlatformIO latest documentation

It recreates .pio dir for sure, because when I delete it, init command recreates it.

BTW, there is no info in the command’s help as well:

✗ pio init --help
Usage: pio init [OPTIONS]

  -d, --project-dir DIRECTORY
  -b, --board ID
  --ide [atom|clion|codeblocks|eclipse|emacs|qtcreator|sublimetext|vim|visualstudio|vscode]
  -e, --environment TEXT          Update existing environment
  -O, --project-option TEXT
  --env-prefix TEXT
  -s, --silent
  -h, --help                      Show this message and exit.

I guess I have an answer to [3]: Running Tools > PlatformIO > Re-Init results in

/usr/local/bin/platformio -c clion init --ide clion
Resolving native dependencies...
Already up-to-date.
Updating metadata for the clion IDE...
Project has been successfully updated!

Process finished with exit code 0

So, I guess those two should be doing exactly the same.

Although… the question would be, what does -c clion change [5]? BTW, this option is not listed in the pio init --help as well.

This is required when you make some changes and add content that needs to be indexed so that CLION can check the code or be used for search or for jumping. For example, after modifying default_envs, different boards need to load different libraries. Or add lib_deps content, the added library needs to be indexed. Otherwise, clion may mark some code as errors.

Yee, the question is: which changes exactly? So I can automate that?

For example: add a file to src [yes/no], add a file to a “library” (lib subdir) [yes/no], add a new “library” [yes/no], change platformio.ini [here i know the answer: yes], anything else [what? yes/no]

For example, after modifying default_envs , different boards need to load different libraries. Or add lib_deps content, the added library needs to be indexed.

That’s under platformio.ini, so I already know I have to re-init then :slight_smile:

I’ve found another one: I need to re–init when I add a new Unity test file. Without the re–init, even a simple #include "unity.h" is marked as not found by CLion.

Since CLion 2023.1 there is no such a thing as “Re-init”, and CMakeLists.txt is gone. Please try the new version

A blog post:

CLion documentation:

1 Like