Getting java.lang.IllegalStateException: unexpanded response file when using SonarLint for VSCode

  • Operating system: win10
  • IDE name and flavor/env: VSCode with mounted network hard drive (D:)
  • SonarLint plugin version: 3.5.3
  • Is connected mode used: no
  • JDK: jdk-14.0.2-jre

I have generated the compile_commands.json with CMake.
Example output:

{
  "directory": "D:/Workspace/build/project/lib",
  "command": "C:\\Users\\LL\\library\\msys2-base-x86_64-20220128\\msys64\\mingw64\\bin\\x86_64-w64-mingw32-g++.exe -DNO_DEPENDENCY_PTHREAD -DWIN32 -DX_EAST -D_CRT_SECURE_NO_WARNINGS @CMakeFiles/lib.dir/includes_CXX.rsp  -std=c++11 /Zc:__cplusplus -g -o CMakeFiles\\lib.dir\\src\\func.cpp.obj -c D:\\Workspace\\project\\lib\\src\\func.cpp",
  "file": "D:/Workspace/project/lib/src/func.cpp"
},

The path to compile commands:

"pathToCompileCommands": "D:\\Workspace\\build\\compile_commands.json",

When SonarLint execute the CFamily sensor a java exception occurs:

[Error - 11:46:14.503] java.lang.IllegalStateException: unexpanded response file
	at com.sonar.cpp.analyzer.ClangDriver.onCapture(ClangDriver.java:336)
	at com.sonar.cpp.analyzer.CompilerDrivers.onCapture(CompilerDrivers.java:35)
	at com.sonar.cpp.plugin.SonarLintSensor.lambda$processCompileCommands$1(SonarLintSensor.java:151)
	at java.base/java.util.HashMap.forEach(Unknown Source)
	at com.sonar.cpp.plugin.SonarLintSensor.processCompileCommands(SonarLintSensor.java:145)
	at com.sonar.cpp.plugin.SonarLintSensor.process(SonarLintSensor.java:131)
	at com.sonar.cpp.plugin.SonarLintSensor.execute(SonarLintSensor.java:94)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:173)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.executeSensor(SensorsExecutor.java:81)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.sensor.SensorsExecutor.execute(SensorsExecutor.java:72)
	at org.sonarsource.sonarlint.core.analysis.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:122)
	at org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer.startComponents(ComponentContainer.java:119)
	at org.sonarsource.sonarlint.core.plugin.commons.pico.ComponentContainer.execute(ComponentContainer.java:104)
	at org.sonarsource.sonarlint.core.analysis.container.module.ModuleContainer.analyze(ModuleContainer.java:71)
	at org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand.execute(AnalyzeCommand.java:58)
	at org.sonarsource.sonarlint.core.analysis.command.AnalyzeCommand.execute(AnalyzeCommand.java:32)
	at org.sonarsource.sonarlint.core.analysis.AnalysisEngine$AsyncCommand.execute(AnalysisEngine.java:152)
	at org.sonarsource.sonarlint.core.analysis.AnalysisEngine.executeQueuedCommands(AnalysisEngine.java:70)
	at java.base/java.lang.Thread.run(Unknown Source)

Welcome to the community, @loic-lopez!

Thank you for the report, we currently do not support response files (in your case @CMakeFiles/lib.dir/includes_CXX.rsp) in the SonarLint plugin, and you can track the progress via CPP-3572 ticket. As a current workaround you can configure CMake to not use response files, by setting the following property:

set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0)
1 Like

Thanks a lot it works!

What is the purposes of CMake response files?

Thanks.

Some systems have a limit on the command line length, and the response file is designed to workaround that, by storing the arguments in the file (called response file) and passing only that file as the argument. If the content of the response file is below this limit, there is no difference in behavior.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.