Dynamic plugin requires restart on Windows

已回答

Hi there!!

I created a dynamic plugin, and deletion/updates indeed work without IDE restarts on MacOS (and I assume Linux, but I don't have a machine to test my plugin on this OS yet).

But there is an issue on Windows. I released an update for my plugin, and when I clicked on update, a popup asking me for restart was displayed.

I checked idea.log and I found the following entry. Keep in mind that I intentionally hid my plugin name and the absolute path (thanks for understanding):

2024-11-06 14:45:28,000 [20600012]   WARN - #c.i.i.p.PluginInstaller - Plugin PluginDescriptor(name=my-plugin-name, id=my-plugin-id, descriptorPath=plugin.xml, path=my-plugin-path, version=0.1.0, package=null, isBundled=false) failed to install without restart. C:\...\JetBrains\IntelliJIdea2024.2\plugins\my-plugin\lib\myplugin.jar: The process cannot access the file because it is being used by another process
java.nio.file.FileSystemException: C:\...\JetBrains\IntelliJIdea2024.2\plugins\my-plugin\lib\myplugin.jar: The process cannot access the file because it is being used by another process
	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:273)
	at java.base/sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:109)
	at java.base/java.nio.file.Files.deleteIfExists(Files.java:1191)
	at com.intellij.openapi.util.io.FileUtilRt.doDelete(FileUtilRt.java:850)
	at com.intellij.openapi.util.io.FileUtilRt.access$100(FileUtilRt.java:26)
	at com.intellij.openapi.util.io.FileUtilRt$1.visitFile(FileUtilRt.java:808)
	at com.intellij.openapi.util.io.FileUtilRt$1.visitFile(FileUtilRt.java:792)
	at java.base/java.nio.file.Files.walkFileTree(Files.java:2786)
	at java.base/java.nio.file.Files.walkFileTree(Files.java:2857)
	at com.intellij.openapi.util.io.FileUtilRt.deleteRecursively(FileUtilRt.java:792)
	at com.intellij.openapi.util.io.NioFiles.deleteRecursively(NioFiles.java:227)
	at com.intellij.ide.plugins.PluginInstaller.unpackPlugin(PluginInstaller.java:209)
	at com.intellij.ide.plugins.PluginInstaller$1.compute(PluginInstaller.java:188)
	at com.intellij.ide.plugins.PluginInstaller$1.compute(PluginInstaller.java:185)
	at com.intellij.openapi.progress.Task$WithResult.run(Task.java:395)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:477)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:133)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressSynchronously$9(CoreProgressManager.java:567)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$new$0(ProgressRunner.java:85)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:249)
	at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:98)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:221)
	at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:49)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:220)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:202)
	at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:98)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$5(ProgressRunner.java:249)
	at com.intellij.openapi.progress.impl.ProgressRunner$ProgressRunnable.run(ProgressRunner.java:501)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$18(ProgressRunner.java:466)
	at com.intellij.util.concurrency.ChildContext$runAsCoroutine$1.invoke(propagation.kt:92)
	at com.intellij.util.concurrency.ChildContext$runAsCoroutine$1.invoke(propagation.kt:92)
	at com.intellij.util.concurrency.ChildContext.runAsCoroutine(propagation.kt:97)
	at com.intellij.util.concurrency.ChildContext.runAsCoroutine(propagation.kt:92)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$19(ProgressRunner.java:464)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
	at java.base/java.lang.Thread.run(Thread.java:1583)

I assume this is not an issue with my plugin since, as I mentioned above, it works well on MacOS (and presumably Linux as well). I suspect this might be an IDE issue, or a Windows issue (maybe Windows Security/Defender).

My IntelliJ version is the latest at this moment (2024.2.4).
The Windows version is 11 Pro 24H2.

I would appreciate any help/hint on this.

Thanks!!

Best regards,
Nahuel

0

Do you access any resources packaged in your plugin's JAR file? Make sure to close all related InputStream under all circumstances etc.

See also https://plugins.jetbrains.com/docs/intellij/dynamic-plugins.html#pluginLoadUnloadEvents and “Resource Cleanup” section below.

0

Hi Yann, thanks for answering!

So sorry for the delay, it's been a complicated week for me.

I tested again on Windows, and I haven't seen the issue happening. Maybe it was a one-time event that won't repeat, at least not consistenly, I'm not sure.
I will release a new version soon and I will try again to see if the error keeps happening.

Thanks!

0

请先登录再写评论。