java.lang.IllegalArgumentException on SonarScanner.MSBuild end

  • Developer Edition Version 7.9.1 (build 27448)
  • SonarScanner for MSBuild 4.7.1
  • Microsoft ® Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
  • openjdk 13.0.1 2019-10-15
  • Microsoft Windows [Version 10.0.18362.418] (x64)

I am new to sonarqube. I have setup my first project and am successfully running sonarscanner on my personal dev system. I am trying to add sonarscanner to by build pipeline in GitLab. At this point I am logged in directly the runner machine in order to debug so GitLab is out of the way. I am getting the following from SonarScanner.MSBuild.exe end

17:17:44.816 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: 'other' has different root
        at java.base/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:404)
        at java.base/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:42)
        at org.sonarsource.scm.git.IncludedFilesRepository.indexFiles(IncludedFilesRepository.java:55)
        at org.sonarsource.scm.git.IncludedFilesRepository.<init>(IncludedFilesRepository.java:40)
        at org.sonarsource.scm.git.GitIgnoreCommand.init(GitIgnoreCommand.java:37)
        at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.index(ProjectFileIndexer.java:104)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:353)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)

I believe this error has to do with absolute vs relative paths. I added /d:sonar.verbose=true and all paths printed are absolute. I don’t know what to do next. Any suggestions?

I tried to paste my command prompt output but it was too big. Let me know what, if any part of the output is helpful and I’ll add it.

In case it’s helpful to anyone, I believe I have solved this.

My build systems use a ram drive on r: which is symlinked to c:\gitlab-runner\builds. All the logs correctly showed the c:… paths and the sonar scan was even working on some systems, but not others. After digging I found that failing systems had worktree = r:/… in .git\config. I’m sure why that is there only some systems but I believe it has to do with the version of gitlab-runner.exe. Anyhow, I reconfigured all build systems to use r:\ directly (no more symlink) and the problem has gone away.

2 Likes