SonarLint Global Settings not creating folder

If your question is about SonarLint in the IntelliJ Platform, VS Code, Visual Studio, or Eclipse, please post it in that sub-category.

Otherwise, please provide:

  • Operating system: Mac OS Sequoia 15.3.1
  • IDE name and flavor/env: Intellij IDEA 2024.1.7

And a thorough description of the problem / question:

Hello again. I’m pushing a little more from when i posted this.

Now i’m trying to retrieve Project information (Quality profiles + rules) even when the option “Bind project” is disabled, retrieving the Project name from the IDE and sending it to a custom proxy API that resolves it.

Im currently creating (if it does not exist) a Settings for the project and a Connection for each project that is opened on the IDE. If it does exist it retrieves it.

I’ve found that this configurations are stored on “/library/caches/Jetbrains/IntellijIdea2024.1/sonarlint” encoding the connection names.

I’m currently creating this connections with the following code:

ServerConnection newServerConnection = ServerConnection.newBuilder().setName(connectionName).setHostUrl(DEFAULT_CONNECTION_URL).build();
SonarLintGlobalSettings globalSettings = Settings.getGlobalSettings();
globalSettings.addServerConnection(newServerConnection);
getService(SonarLintGlobalSettingsStore.class).save(globalSettings);

The main issue is that sometimes the folders and files on the FileSystem are created immediately and it works fine but sometimes it does not and throws this error:

Caused by: org.sonarsource.sonarlint.core.serverconnection.storage.StorageException: Failed to read file: /Users/myuser/Library/Caches/JetBrains/IntelliJIdea2024.1/sonarlint/storage/636f6e6e656374696f6e2d636f64652d636f7665726167652d617069/projects/636f64652d636f7665726167652d617069/analyzer_config.pb

¿Is there any way to “force” this folders creation so the Core can retrieve this information when needed?

Thanks for reading and the help!

Hello Felipe,

I am still not sure I understand what you are trying to achieve, but I will try to answer.

The folder is indeed created and populated by SLCORE in response to a connection creation and project binding. This process of fetching data from the server and persisting it on the file system is what we call the “synchronization”. This is managed by SLCORE and clients have no control over that. They cannot force it. But this is maybe something you can modify as part of your effort.

If it helps, you can turn the synchronization off completely. It’s one of the parameters in FeatureFlagsDto.

The code you shared for creating the connection might not be sufficient, you also need to notify the backend about this new connection via ConnectionRpcService.didUpdateConnections(). You can check how it’s done when we create connections in other places.

Hope this helps