obiscr / ChatGPT

This project is a plugin that supports ChatGPT running on JetBrains series IDE.
https://plugins.jetbrains.com/plugin/20603-chatgpt
Other
1.02k stars 229 forks source link

IntelliJ ChatGPT Canvas is empty (due to PluginException: Cannot init toolwindow a.a.a.A) #285

Closed ascheman closed 5 months ago

ascheman commented 1 year ago

Currently I cannot use the IntelliJ ChatGPT extension, since it is simply empty:

image

Perhaps this has nothing directly todo with ChatGPT? On the other hand this is the only plugin which fails to start ...

I see the following stack trace:

com.intellij.diagnostic.PluginException: Cannot init toolwindow a.a.a.A@4744b1b1 [Plugin: ChatGPT]
    at com.intellij.toolWindow.ToolWindowSetInitializerKt.registerToolWindows(ToolWindowSetInitializer.kt:191)
    at com.intellij.toolWindow.ToolWindowSetInitializerKt.access$registerToolWindows(ToolWindowSetInitializer.kt:1)
    at com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1$1.invoke(ToolWindowSetInitializer.kt:129)
    at com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1$1.invoke(ToolWindowSetInitializer.kt:121)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:248)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:199)
    at com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1.invokeSuspend(ToolWindowSetInitializer.kt:121)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:193)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
    at com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:478)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:79)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:121)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:792)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$10(IdeEventQueue.kt:589)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWithoutImplicitRead(ApplicationImpl.java:1485)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:589)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 74, end 70, length 70
    at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
    at java.base/java.lang.String.substring(String.java:2709)
    at java.base/java.lang.String.substring(String.java:2682)
    at com.neva.commons.gitignore.ExcludeUtils.getRelativePath(ExcludeUtils.java:79)
    at com.neva.commons.gitignore.GitIgnore.isExcluded(GitIgnore.java:41)
    at a.a.a.c.aN.shouldIncludeDirectory(aN.java:106)
    at a.a.a.c.aN.buildFileTreeRecursive(aN.java:36)
    at a.a.a.c.aN.buildFileTree(aN.java:21)
    at a.a.a.c.W.<init>(W.java:73)
    at a.a.a.c.l.<init>(l.java:135)
    at b.a.l.<init>(l.java:20)
    at a.a.a.A.createToolWindowContent(A.java:55)
    at com.intellij.openapi.wm.impl.ToolWindowImpl.createContentIfNeeded(ToolWindowImpl.kt:554)
    at com.intellij.openapi.wm.impl.ToolWindowImpl.scheduleContentInitializationIfNeeded$intellij_platform_ide_impl(ToolWindowImpl.kt:533)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.doShowWindow(ToolWindowManagerImpl.kt:1014)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.showToolWindowImpl(ToolWindowManagerImpl.kt:951)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.showToolWindowImpl$default(ToolWindowManagerImpl.kt:937)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.registerToolWindow$intellij_platform_ide_impl(ToolWindowManagerImpl.kt:1121)
    at com.intellij.toolWindow.ToolWindowSetInitializerKt.registerToolWindows(ToolWindowSetInitializer.kt:181)
    ... 43 more
obiscr commented 1 year ago

Hi, I'm sorry I can't reproduce this here. I'm guessing that this problem, though, may occur when opening some projects, but not others. Where the problem occurs is when trying to parse the .gitignore file.

Could you please share the .gitignore of the project where the problem occurs?

BTW, if it involves sensitive information, you can send it to my email.

ascheman commented 1 year ago

The problem occurred in a multi-module project. When I was closing all modules, and opened all of them as separate projects, the problem vanished. None of the included .gitignore files where somehow special (only the typical .idea/, .iml, .log, ...) exclusions for Git.

Nevertheless, I'd appreciate if you could catch any exception in a.a.a.c.aN.shouldIncludeDirectory and simply exclude the directory just investigated.

obiscr commented 1 year ago

Thank you for the information and I will test it.

obiscr commented 1 year ago

@ascheman Hello, I tested several multi module projects, each with a .gitignore file, but still did not reproduce this issue. Could you provide a demo project that may encounter this issue?

Thanks!

ascheman commented 1 year ago

Thanks for testing it, @obiscr. I think it is not a special problem of Git or the .gitignore file. All of them look OK, so it's hard to reproduce the error. I guess it is kind of multiple factors coming together.

Therefore I was rather thinking of a generic catch clause in a.a.a.c.aN.shouldIncludeDirectory. You seem to be calling com.neva.commons.gitignore.GitIgnore.isExcluded. If it throws an error, simply log the exception, exclude the directory (since it is causing a problem) and go ahead - no reason to stop initializing ChatGPT. I even wonder why you check for .gitignore files in a client to some remote service? If you could also log the directory name where the problem occurs, we probably get a hint about the real problem in the future.

obiscr commented 1 year ago

This is a related logic of codebase feature, it will prepare some needed data in advance to initialise the component.

You are right. It might be better to initialise that data when using the codebase feature.

That way, even if some users don't use the codebase feature, it won't affect other features.

pavelbar commented 1 year ago

I have the same problem. If I create a new empty project then it works fine, but if I try to open my project then it breaks.

I started seeing this problem after upgrading CLion to version 2023.*, this was not observed on version 2022.

Here is my call stack.


com.intellij.diagnostic.PluginException: Cannot init toolwindow a.a.a.A@3c3aa38c [Plugin: ChatGPT]
    at com.intellij.toolWindow.ToolWindowSetInitializerKt.registerToolWindows(ToolWindowSetInitializer.kt:191)
    at com.intellij.toolWindow.ToolWindowSetInitializerKt.access$registerToolWindows(ToolWindowSetInitializer.kt:1)
    at com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1$1.invoke(ToolWindowSetInitializer.kt:129)
    at com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1$1.invoke(ToolWindowSetInitializer.kt:121)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:248)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:199)
    at com.intellij.toolWindow.ToolWindowSetInitializer$createAndLayoutToolWindows$entries$1.invokeSuspend(ToolWindowSetInitializer.kt:121)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:193)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
    at com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:478)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:79)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:121)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:792)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$10(IdeEventQueue.kt:589)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWithoutImplicitRead(ApplicationImpl.java:1485)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:589)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Caused by: java.lang.StringIndexOutOfBoundsException: begin 53, end 30, length 30
    at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4606)
    at java.base/java.lang.String.substring(String.java:2709)
    at java.base/java.lang.String.substring(String.java:2682)
    at com.neva.commons.gitignore.ExcludeUtils.getRelativePath(ExcludeUtils.java:79)
    at com.neva.commons.gitignore.GitIgnore.isExcluded(GitIgnore.java:41)
    at a.a.a.c.aN.shouldIncludeDirectory(aN.java:106)
    at a.a.a.c.aN.buildFileTreeRecursive(aN.java:36)
    at a.a.a.c.aN.buildFileTree(aN.java:21)
    at a.a.a.c.W.<init>(W.java:73)
    at a.a.a.c.l.<init>(l.java:135)
    at b.a.l.<init>(l.java:20)
    at a.a.a.A.createToolWindowContent(A.java:55)
    at com.intellij.openapi.wm.impl.ToolWindowImpl.createContentIfNeeded(ToolWindowImpl.kt:554)
    at com.intellij.openapi.wm.impl.ToolWindowImpl.scheduleContentInitializationIfNeeded$intellij_platform_ide_impl(ToolWindowImpl.kt:533)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.doShowWindow(ToolWindowManagerImpl.kt:1014)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.showToolWindowImpl(ToolWindowManagerImpl.kt:951)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.showToolWindowImpl$default(ToolWindowManagerImpl.kt:937)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.registerToolWindow$intellij_platform_ide_impl(ToolWindowManagerImpl.kt:1121)
    at com.intellij.toolWindow.ToolWindowSetInitializerKt.registerToolWindows(ToolWindowSetInitializer.kt:181)
    ... 43 more

UPDATE: Downgrading CLion to the older version 2022.3.3 solves the problem. https://www.jetbrains.com/toolbox-app/

UPDATE: Same problem on CLion 2022.3.3. Invalidating the cache (File-invalidate cache) solves the problem

obiscr commented 1 year ago

@pavelbar Thanks for sharing the solution. Yes, this is a known issue. It will be fixed in a future release.

obiscr commented 5 months ago

Sorry for the late reply. This issue has been fixed in the latest version 3.3.1. Please update to version 3.3.1.