intellij 从2020升级到2023 踩坑实录

1.下载新版本intellij

工作机器上的intellij版本为2020社区版,版本比较老旧,需要进行升级。IDE这种提高生产力的工具,还是蛮重要的,也是值得稍微多花点时间研究一下的。升级之前就预计到了不会是那么简单,后面事实也证明确实很麻烦,特意记录升级过程,为后来人指明方向。

首先下载新版本,这个没什么好说的,直接去jetbrain官网,根据自己的操作系统下载对应的intellij版本,我的机器是ubuntu,下载对应的linux .tar.gz然后解压就好。

2.启动intellij报错,查找对应日志文件

解压以后,会得到一个ideaIC-2023.1文件夹,文件夹里面是idea-IC-231.8109.175,进去可以看到结构

tree -L 1 idea-IC-231.8109.175

intellij 从2020升级到2023 踩坑实录_第1张图片

cd到bin里面,里面有idea.sh文件。最理想的情况,就是执行idea.sh文件,然后IDE正常启动。当然理想情况是不可能发生的,一般都会各种意外。

执行idea.sh的时候就报错,无法正常启动,需要去查log。2023版各文件的位置为

配置(idea.config.path)~/.config/JetBrains/IdeaIC2023.1
插件(idea.plugins.path)~/.local/share/JetBrains/IdeaIC2023.1
系统(idea.system.path)~/.cache/JetBrains/IdeaIC2023.1
日志(idea.log.path)~/.cache/JetBrains/IdeaIC2023.1/log

IDE启动的日志就在~/.cache/JetBrains/IdeaIC2023.1/log中

tree -L 1 log

intellij 从2020升级到2023 踩坑实录_第2张图片
启动日志就在idea.log里面。

3.排查log

在idea.log中,开始排查错误信息。

2023-04-20 14:16:24,412 [     78] SEVERE - #c.i.i.p.PluginManager - `include` is supported only on a root level ([row,col,system-id]: [718,5,"/home/xxx/.local/share/JetBrains/IdeaIC2023.1/odps-studio-intellij/lib/odps-studio-intellij-3.6.2.jar"])
java.lang.Throwable: `include` is supported only on a root level ([row,col,system-id]: [718,5,"/home/xxx/.local/share/JetBrains/IdeaIC2023.1/odps-studio-intellij/lib/odps-studio-intellij-3.6.2.jar"])
        at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
        at com.intellij.ide.plugins.XmlReader.checkXInclude(XmlReader.kt:499)
        at com.intellij.ide.plugins.XmlReader.access$checkXInclude(XmlReader.kt:1)
        at com.intellij.ide.plugins.XmlReader.readExtensions(XmlReader.kt:408)
        at com.intellij.ide.plugins.XmlReader.readRootElementChild(XmlReader.kt:264)
        ...

最开始看到有抛上述异常,开始去找相关错误信息。找了半天,没发现有啥好办法。后来证明,这个东西暂时不影响正常使用…

继续查看日志,发现如下一段错误日志。

2023-04-20 14:16:26,014 [   1680]   INFO - STDERR - Start Failed
2023-04-20 14:16:26,014 [   1680]   INFO - STDERR - Internal error. Please refer to https://jb.gg/ide/critical-startup-errors
2023-04-20 14:16:26,015 [   1681]   INFO - STDERR -
2023-04-20 14:16:26,015 [   1681]   INFO - STDERR - com.intellij.diagnostic.PluginException: Fatal error initializing 'com.aliyun.odps.studio.intellij.StudioMain' [Plugin: OdpsStudio]
2023-04-20 14:16:26,015 [   1681]   INFO - STDERR -     at com.intellij.serviceContainer.ComponentManagerImpl.handleInitComponentError$intellij_platform_serviceContainer(ComponentManagerImpl.kt:612)
2023-04-20 14:16:26,015 [   1681]   INFO - STDERR -     at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:59)
2023-04-20 14:16:26,015 [   1681]   INFO - STDERR -     at com.intellij.serviceContainer.BaseComponentAdapter.doCreateInstance(BaseComponentAdapter.kt:154)
2023-04-20 14:16:26,016 [   1682]   INFO - STDERR -     at com.intellij.serviceContainer.BaseComponentAdapter.createInstance$lambda$1(BaseComponentAdapter.kt:133)
2023-04-20 14:16:26,016 [   1682]   INFO - STDERR -     at com.intellij.openapi.progress.Cancellation.computeInNonCancelableSection(Cancellation.java:99)
2023-04-20 14:16:26,016 [   1682]   INFO - STDERR -     at com.intellij.serviceContainer.BaseComponentAdapter.createInstance(BaseComponentAdapter.kt:132)
2023-04-20 14:16:26,016 [   1682]   INFO - STDERR -     at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:92)
2023-04-20 14:16:26,016 [   1682]   INFO - STDERR -     at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:77)
2023-04-20 14:16:26,017 [   1683]   INFO - STDERR -     at com.intellij.serviceContainer.ComponentManagerImpl$createInitOldComponentsTask$1.invoke(ComponentManagerImpl.kt:428)
2023-04-20 14:16:26,017 [   1683]   INFO - STDERR -     at com.intellij.serviceContainer.ComponentManagerImpl$createInitOldComponentsTask$1.invoke(ComponentManagerImpl.kt:426)
2023-04-20 14:16:26,017 [   1683]   INFO - STDERR -     at com.intellij.idea.ApplicationLoader$initApplicationImpl$appInitializedListeners$1$1$2$1.invokeSuspend(ApplicationLoader.kt:161)
2023-04-20 14:16:26,017 [   1683]   INFO - STDERR -     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2023-04-20 14:16:26,017 [   1683]   INFO - STDERR -     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
2023-04-20 14:16:26,017 [   1683]   INFO - STDERR -     at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
2023-04-20 14:16:26,018 [   1684]   INFO - STDERR -     at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:788)
2023-04-20 14:16:26,018 [   1684]   INFO - STDERR -     at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
2023-04-20 14:16:26,018 [   1684]   INFO - STDERR -     at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:731)
2023-04-20 14:16:26,018 [   1684]   INFO - STDERR -     at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
2023-04-20 14:16:26,018 [   1684]   INFO - STDERR -     at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
2023-04-20 14:16:26,018 [   1684]   INFO - STDERR -     at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:758)
2023-04-20 14:16:26,019 [   1685]   INFO - STDERR -     at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:302)
2023-04-20 14:16:26,019 [   1685]   INFO - STDERR -     at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
2023-04-20 14:16:26,019 [   1685]   INFO - STDERR -     at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
2023-04-20 14:16:26,019 [   1685]   INFO - STDERR -     at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
2023-04-20 14:16:26,019 [   1685]   INFO - STDERR -     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
2023-04-20 14:16:26,019 [   1685]   INFO - STDERR -     at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
2023-04-20 14:16:26,020 [   1686]   INFO - STDERR -     at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
2023-04-20 14:16:26,020 [   1686]   INFO - STDERR - Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.log4j.Category.getAllAppenders()" because the return value of "org.apache.log4j.Logger.getParent()" is null
2023-04-20 14:16:26,020 [   1686]   INFO - STDERR -     at com.aliyun.odps.studio.intellij.ide.IntellijLogger.getInstance(IntellijLogger.java:48)
2023-04-20 14:16:26,020 [   1686]   INFO - STDERR -     at com.aliyun.odps.studio.intellij.ide.IntellijLogger.info(IntellijLogger.java:21)
2023-04-20 14:16:26,020 [   1686]   INFO - STDERR -     at com.aliyun.odps.studio.component.util.DerbyDBUtil.initOptionPath(DerbyDBUtil.java:23)
2023-04-20 14:16:26,020 [   1686]   INFO - STDERR -     at com.aliyun.odps.studio.intellij.StudioMain.initComponent(StudioMain.java:94)
2023-04-20 14:16:26,020 [   1686]   INFO - STDERR -     at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:45)
2023-04-20 14:16:26,021 [   1687]   INFO - STDERR -     ... 25 more
2023-04-20 14:16:26,021 [   1687]   INFO - STDERR -
2023-04-20 14:16:26,021 [   1687]   INFO - STDERR - -----
2023-04-20 14:16:26,021 [   1687]   INFO - STDERR - Your JRE: 17.0.6+10-b829.5 amd64 (JetBrains s.r.o.)
2023-04-20 14:16:26,021 [   1687]   INFO - STDERR - /home/xxx/ideaIC-2023.1/idea-IC-231.8109.175/jbr

Internal error. Please refer to https://jb.gg/ide/critical-startup-errors
这一句很关键,根据这一句搜到这个老哥的总结。

https://intellij-support.jetbrains.com/hc/en-us/articles/360007568559?page=8

里面有这么一段

There are multiple possible causes for this issue: broken or incompatible plug-in, corrupted IDE installation files, failed patch update, broken caches or damaged configuration.

It may be hard to guess the root case from the exception stacktrace.

再结合下面的错误信息,基本就是broken or incompatible plug-in的原因了。

看idea-IC-231.8109.175文件夹里有一个plugins, 最开始以为是在这个文件夹下面的。但是查了好久,也木有发现OdpsStudio相关的插件呀,相当郁闷,也不知道为什么intellij启动跟aliyun有什么关系。

后来想起来,还有一个插件相关的目录
~/.local/share/JetBrains/IdeaIC2023.1

cd到这个目录,果然发现有个跟OdpsStudio相关的目录,不管三七二十一,直接删掉。

再执行idea.sh文件,世界和平,正常启动。

4.创建快捷方式

每次通过执行idea.sh的方式启动肯定不方便,需要创建快捷方式快速启动。

网上的教程都是告诉你创建idea.desktop(应该是老版本)文件去实现。但是新版本的intellij提供了更好的方法:

Tools菜单下面有个create desktop entry选项。点击这个选项,可以在/usr/share/applications中直接生成jetbrains-idea-ce.desktop文件。

但是重点来了,发现每次点快捷方式,启动的还是原来2020老版本的IDE!!!

试了好几次,重启大法也用上了,还是一样。

突然灵光一现想起一个问题,是不是原来就有这个文件,虽然在新版本IDE 里执行了create desktop entry选项,文件没有更新啊

于是把原有的文件删掉,重新再点击create desktop entry选项,然后发现应用程序里的快捷方式图标,更新了。这个时候再启动,也是2023新版的IDE,完美解决。

你可能感兴趣的:(vim,sublime,ide,java,intellij-idea,启动报错)