alex1701c / JetBrainsRunner

A Krunner Plugin which allows you to open your recent projects
GNU Lesser General Public License v3.0
53 stars 4 forks source link

Projects visible but won't start (only last used project is opened) #35

Closed ghost closed 1 year ago

ghost commented 1 year ago

All projects are found, recentProjects.xml is fine, most recent version of everything.

So far tested and affects IntelliJ, Clion and PyCharm

Running krunner through the terminal with kstart5 --windowclass krunner krunner and then trying to launch an IntelliJ Project, then Clion Project, then PyCharm project.

Behaviour: The apps open as if I just ran them normally without the jetbrains runner, on their respective last open project instead of the one selected in krunner.

Output:

kf.sonnet.core: No language dictionaries for the language: "en_US"
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
kf.sonnet.core: No language dictionaries for the language: "en_US"
/bin/sh: line 1: [0.000s][warning][gc]: command not found
QCommandLineParser: argument list cannot be empty, it should contain at least the executable name
kf.sonnet.core: No language dictionaries for the language: "en_US"
2023-01-07 03:05:22,368 [   1517]   WARN - #c.i.e.RunManager - Must be not called before project components initialized
2023-01-07 03:05:23,115 [   2264] SEVERE - #c.i.o.a.TransactionGuardImpl - Write-unsafe context! Model changes are allowed from write-safe contexts only. Please ensure you're using invokeLater/invokeAndWait with a correct modality state (not "any"). See TransactionGuard documentation for details.
  current modality=ModalityState.NON_MODAL
java.lang.Throwable: Write-unsafe context! Model changes are allowed from write-safe contexts only. Please ensure you're using invokeLater/invokeAndWait with a correct modality state (not "any"). See TransactionGuard documentation for details.
  current modality=ModalityState.NON_MODAL
        at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
        at com.intellij.openapi.application.TransactionGuardImpl.assertWriteActionAllowed(TransactionGuardImpl.java:135)
        at com.intellij.psi.impl.PsiModificationTrackerImpl.fireEvent(PsiModificationTrackerImpl.java:80)
        at com.intellij.psi.impl.PsiModificationTrackerImpl.incCountersInner(PsiModificationTrackerImpl.java:86)
        at com.intellij.psi.impl.PsiModificationTrackerImpl.treeChanged(PsiModificationTrackerImpl.java:96)
        at com.intellij.psi.impl.PsiManagerImpl.fireEvent(PsiManagerImpl.java:340)
        at com.intellij.psi.impl.PsiManagerImpl.beforeChildrenChange(PsiManagerImpl.java:233)
        at com.intellij.psi.impl.file.impl.FileManagerImpl.forceReload(FileManagerImpl.java:138)
        at com.intellij.psi.impl.file.impl.PsiVFSListener.propertyChanged(PsiVFSListener.java:356)
        at com.intellij.psi.impl.file.impl.PsiVFSListener.fireForGrouped(PsiVFSListener.java:792)
        at one.util.streamex.CollapseSpliterator.accept(CollapseSpliterator.java:152)
        at one.util.streamex.CollapseSpliterator.forEachRemaining(CollapseSpliterator.java:142)
        at one.util.streamex.AbstractStreamEx.forEach(AbstractStreamEx.java:352)
        at com.intellij.psi.impl.file.impl.PsiVFSListener.groupAndFire(PsiVFSListener.java:765)
        at com.intellij.psi.impl.file.impl.PsiVFSListener.after(PsiVFSListener.java:754)
        at com.intellij.psi.impl.file.impl.PsiVFSListener$1.after(PsiVFSListener.java:149)
        at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:655)
        at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:625)
        at com.intellij.util.messages.impl.MessageBusImplKt.executeOrAddToQueue(MessageBusImpl.kt:466)
        at com.intellij.util.messages.impl.ToDirectChildrenMessagePublisher.publish$intellij_platform_core(CompositeMessageBus.kt:262)
        at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:421)
        at jdk.proxy2/jdk.proxy2.$Proxy105.after(Unknown Source)
        at com.intellij.util.FileContentUtilCore.lambda$reparseFiles$0(FileContentUtilCore.java:47)
        at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:955)
        at com.intellij.util.FileContentUtilCore.reparseFiles(FileContentUtilCore.java:35)
        at com.intellij.openapi.file.exclude.PersistentFileSetManager.lambda$onFileSettingsChanged$1(PersistentFileSetManager.java:64)
        at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:194)
        at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:813)
        at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:429)
        at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:74)
        at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:114)
        at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:36)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
        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:749)
        at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:909)
        at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:756)
        at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$5(IdeEventQueue.java:437)
        at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:772)
        at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:436)
        at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
        at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:615)
        at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:434)
        at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:813)
        at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:480)
        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)
2023-01-07 03:05:23,119 [   2268] SEVERE - #c.i.o.a.TransactionGuardImpl - IntelliJ IDEA 2022.3.1  Build #IU-223.8214.52
2023-01-07 03:05:23,119 [   2268] SEVERE - #c.i.o.a.TransactionGuardImpl - JDK: 17.0.5; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2023-01-07 03:05:23,119 [   2268] SEVERE - #c.i.o.a.TransactionGuardImpl - OS: Linux
/bin/sh: line 1: [0.000s][warning][gc]: command not found
QCommandLineParser: argument list cannot be empty, it should contain at least the executable name
kf.sonnet.core: No language dictionaries for the language: "en_US"
2023-01-07 03:13:30,085 [   5023]   WARN - #c.i.f.ProductivityFeaturesRegistryImpl - Feature with id 'codeassists.context.actions' is overridden by: id = [codeassists.context.actions], displayName = [Context actions], groupId = [codeassists], usageCount = [0]
2023-01-07 03:13:30,085 [   5023]   WARN - #c.i.f.ProductivityFeaturesRegistryImpl - Feature with id 'codeassists.generate.code' is overridden by: id = [codeassists.generate.code], displayName = [Generate code], groupId = [codeassists], usageCount = [0]
2023-01-07 03:13:30,086 [   5024]   WARN - #c.i.f.ProductivityFeaturesRegistryImpl - Feature with id 'codeassists.quickdefinition' is overridden by: id = [codeassists.quickdefinition], displayName = [Quick Definition lookup], groupId = [codeassists], usageCount = [0]
2023-01-07 03:13:30,410 [   5348]   WARN - #c.i.e.RunManager - Must be not called before project components initialized
QCommandLineParser: argument list cannot be empty, it should contain at least the executable name
kf.sonnet.core: No language dictionaries for the language: "en_US"
2023-01-07 03:13:35,572 [  10510]   WARN - #c.i.u.x.Binding - no accessors for com.intellij.openapi.projectRoots.Sdk
/bin/sh: line 1: CompileCommand:: command not found
2023-01-07 03:13:54,460 [  29398] SEVERE - #c.i.u.m.i.MessageBusImpl - Already disposed: MessageBus(owner=Application  (containerState DISPOSE_IN_PROGRESS)  (WA inProgress) (exit in progress), disposeState= 1)
java.lang.Throwable: Already disposed: MessageBus(owner=Application  (containerState DISPOSE_IN_PROGRESS)  (WA inProgress) (exit in progress), disposeState= 1)
        at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
        at com.intellij.util.messages.impl.MessageBusImpl.checkNotDisposed$intellij_platform_core(MessageBusImpl.kt:177)
        at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:420)
        at jdk.proxy2/jdk.proxy2.$Proxy94.afterTaskStart(Unknown Source)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:117)
        at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$6(CoreProgressManager.java:474)
        at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
        at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
        at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:589)
        at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:664)
        at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:620)
        at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:588)
        at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
        at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
        at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
        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.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
        at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
        at java.base/java.lang.Thread.run(Thread.java:833)
2023-01-07 03:13:54,461 [  29399] SEVERE - #c.i.u.m.i.MessageBusImpl - CLion 2022.3.1  Build #CL-223.8214.51
2023-01-07 03:13:54,461 [  29399] SEVERE - #c.i.u.m.i.MessageBusImpl - JDK: 17.0.5; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2023-01-07 03:13:54,461 [  29399] SEVERE - #c.i.u.m.i.MessageBusImpl - OS: Linux
QCommandLineParser: argument list cannot be empty, it should contain at least the executable name
kf.sonnet.core: No language dictionaries for the language: "en_US"
/bin/sh: line 1: CompileCommand:: command not found
2023-01-07 03:13:57,909 [    674]   WARN - #c.i.f.ProductivityFeaturesRegistryImpl - Feature with id 'codeassists.context.actions' is overridden by: id = [codeassists.context.actions], displayName = [Context actions], groupId = [codeassists], usageCount = [0]
2023-01-07 03:13:57,909 [    674]   WARN - #c.i.f.ProductivityFeaturesRegistryImpl - Feature with id 'codeassists.generate.code' is overridden by: id = [codeassists.generate.code], displayName = [Generate code], groupId = [codeassists], usageCount = [0]
2023-01-07 03:13:57,910 [    675]   WARN - #c.i.f.ProductivityFeaturesRegistryImpl - Feature with id 'codeassists.quickdefinition' is overridden by: id = [codeassists.quickdefinition], displayName = [Quick Definition lookup], groupId = [codeassists], usageCount = [0]
2023-01-07 03:13:58,383 [   1148]   WARN - #c.i.e.RunManager - Must be not called before project components initialized
/bin/sh: line 1: CompileCommand:: command not found
QCommandLineParser: argument list cannot be empty, it should contain at least the executable name
kf.sonnet.core: No language dictionaries for the language: "en_US"
/bin/sh: line 1: CompileCommand:: command not found
alex1701c commented 1 year ago

I can not reproduce on my system.

Could you maybe modify the JetbrainsRunner::run method in jetbrainsrunner.cpp file and attach the log message?

void JetbrainsRunner::run(const Plasma::RunnerContext & context, const Plasma::QueryMatch &match)
{
qWarning().noquote()<<"running executable line" <<match.data().toString();
    Q_UNUSED(context)
    auto *job = new KIO::CommandLauncherJob(match.data().toString());
    job->start();
}
ghost commented 1 year ago
running executable line $(/usr/bin/intellij-idea-ultimate-edition ) /home/deckweiss/Projects/InvoiceTrainer/Backend

Path is correct, the project opens fine from IntelliJ itself or even from terminal or dolphin "open with".

btw, the big exception seems unrelated. It only happens if IntelliJ is not already running. If it is running and I call the runner to open the Backend project, I get only the single line of debug output you told me to add and then nothing happens.


Edit:

Ah I see the cause of the error. This is my desktop files exec line : Exec=$(/usr/bin/intellij-idea-ultimate-edition %f)

I modified it to run all jetbrains apps in a subshell, because otherwise it would sometimes crash my whole plasma session (in some edgecases, due to some java runtime stack error. I had a project where it constantly happened, in other projects extremely rarely and in others never, didn't dig any deeper - a subshell solution seemed to make sense)

The %f is a desktop file exec key https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables which signals where the path to the file goes, when opening a file with a program. It seems like your code ignores that and instead appends the path to whatever is in the desktop file.

If you feel like fixing this - I think you can either handle exec keys properly and append only when they arent present. Or work around them by calling the app binary directly by scanning where it is installed, since you read the desktop file anyway, you'd need only one additional step to find where the binary is located with for example whereis intellij-idea-ultimate-edition or searching the $PATH (desktop files don't need to define the full path)

jetbrains-idea.desktop.txt

alex1701c commented 1 year ago

It seems like your code ignores that and instead appends the path to whatever is in the desktop file.

Yeah, because (at least in the past) it was unreliable. Some desktop files had %f, other %u and some did not have any. I will need to try out how the KDE desktop exec parser handles such cases.