Error with bare repository

Hi @marcelomartins,

I’m encountering here a similar problem when trying to analyze some files with SonarLint in my IntelliJ:

  • Operating system: Windows 11
  • SonarLint plugin version: 10.8.1.79205
  • IntelliJ version: 2024.1.5 (Build #IU-241.18968.26)
  • Programming Language: Java, Javascript, Typescript
  • The plugin is in connected mode
    • Connecte to SonarQube: SonarQube Community Edition Version 9.9.0.65466

In my case the following error is logged as soon as I try to analyse a file:

[2024-08-15T08:23:56.578] [SonarLint Server RPC request executor] ERROR org.eclipse.lsp4j.jsonrpc.RemoteEndpoint - Internal error: org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
java.util.concurrent.CompletionException: org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:649)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
	at org.eclipse.jgit.lib.Repository.getWorkTree(Repository.java:1582)
	at org.sonarsource.sonarlint.core.commons.util.git.GitUtils.createSonarLintGitIgnore(GitUtils.java:133)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.toInputFiles(AnalysisService.java:752)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.getAnalysisConfigForEngine(AnalysisService.java:273)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.analyze(AnalysisService.java:640)
	at org.sonarsource.sonarlint.core.rpc.impl.AnalysisRpcServiceDelegate.lambda$analyzeFilesAndTrack$8(AnalysisRpcServiceDelegate.java:136)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.lambda$requestAsync$0(AbstractRpcServiceDelegate.java:67)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.computeWithLogger(AbstractRpcServiceDelegate.java:135)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.lambda$requestAsync$1(AbstractRpcServiceDelegate.java:65)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	... 4 common frames omitted

Error during analysis ID 59fb24cd-d638-41c1-be5e-c0de40e4be04
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:204)
	at org.sonarsource.sonarlint.core.rpc.protocol.SingleThreadedMessageConsumer.lambda$new$0(SingleThreadedMessageConsumer.java:51)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

Analysing 'DocumentManagementBean.java' (ID 1ad51ac1-1a4d-4762-b8b4-a0f9f5631803)...
 [2024-08-15T08:23:57.335] [SonarLint Server RPC request executor] ERROR org.eclipse.lsp4j.jsonrpc.RemoteEndpoint - Internal error: org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
java.util.concurrent.CompletionException: org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:649)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
	at org.eclipse.jgit.lib.Repository.getWorkTree(Repository.java:1582)
	at org.sonarsource.sonarlint.core.commons.util.git.GitUtils.createSonarLintGitIgnore(GitUtils.java:133)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.toInputFiles(AnalysisService.java:752)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.getAnalysisConfigForEngine(AnalysisService.java:273)
	at org.sonarsource.sonarlint.core.analysis.AnalysisService.analyze(AnalysisService.java:640)
	at org.sonarsource.sonarlint.core.rpc.impl.AnalysisRpcServiceDelegate.lambda$analyzeFilesAndTrack$8(AnalysisRpcServiceDelegate.java:136)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.lambda$requestAsync$0(AbstractRpcServiceDelegate.java:67)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.computeWithLogger(AbstractRpcServiceDelegate.java:135)
	at org.sonarsource.sonarlint.core.rpc.impl.AbstractRpcServiceDelegate.lambda$requestAsync$1(AbstractRpcServiceDelegate.java:65)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
	... 4 common frames omitted

Error during analysis ID 1ad51ac1-1a4d-4762-b8b4-a0f9f5631803
org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Internal error.
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:204)
	at org.sonarsource.sonarlint.core.rpc.protocol.SingleThreadedMessageConsumer.lambda$new$0(SingleThreadedMessageConsumer.java:51)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

I don’t know, what is wrong here, I can only guess, that the latest SonarLint version uses a feature (worktree) of the server which is only supported in newer version.

1 Like

Ahh - from looking at the stacktrace, I think my error may be not be related to the one of the initial post.
It seems that the plugin has problems connecting to our Git repository, which is a bare repository.

1 Like

One more information to this issue:

There is an error ticket at Eclipse which treats exactly this problem, found in JGit:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=477475

I thought this was fixed already and until last week, my SonarLint plugin was working without that error.

2 Likes

I installed the plugin version SonarLint 10.7.0.78874. With that version, the plugin works as expected. With relase 10.8.0.79133 and 10.8.1.79205 the error occurs.

2 Likes

Then the question is how to downgrade this plugin?

Hi @marcelomartins, @tschindler,

the instructions on how to downgrade are described in the docs.

This is flagged for our colleagues working on the Git integration of SonarLint; please be a bit patient with them due to the holiday season. We are currently not that many around.

Best,
Tobias

1 Like

Hello,

I followed the instructions from SonarSource support and upgraded the plugin again to version 10.8.1.79205 and surprisingly it started working again!!
Thank you very much anyway.

1 Like

I’m getting this same error after updating from 10.6. The error happens with both 10.7 and 10.8.

CLion 2023.2.1
Connected to Sonarqube

Hello,

I investigated the issue. The root cause is assuming the repo is always a non-bare repo. Because of the false assumption, the current version tries to access the work tree of bare repositories that don’t have it by definition. I created two tickets for the fix.

1 Like