WSL2でIntelliJを正しく設定する方法 質問する

WSL2でIntelliJを正しく設定する方法 質問する

WSL2 で作成されたプロジェクトを実行できません。このエラーが発生しています。原因が何かわかる方はいらっしゃいますか?

Abnormal build process termination: 
C:\WINDOWS\system32\wsl.exe --distribution Ubuntu-20.04 --exec /bin/sh -c "cd /home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server && /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Xmx700m -Djava.awt.headless=true -Djdt.compiler.useSingleThread=true -Dpreload.project.path=/home/jakub/test -Dpreload.config.path=/mnt/c/Users/Z004506P/AppData/Roaming/JetBrains/IntelliJIdea2021.1/options -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Dio.netty.initialSeedUniquifier=-636684381209623859 -Djps.in.wsl=true -Dfile.encoding=windows-1252 -Duser.language=en -Duser.country=US -Didea.paths.selector=IntelliJIdea2021.1 '-Didea.home.path=/mnt/c/Program Files/JetBrains/IntelliJ IDEA 2021.1' -Didea.config.path=/mnt/c/Users/Z004506P/AppData/Roaming/JetBrains/IntelliJIdea2021.1 -Didea.plugins.path=/mnt/c/Users/Z004506P/AppData/Roaming/JetBrains/IntelliJIdea2021.1/plugins -Djps.log.dir=/mnt/c/Users/Z004506P/AppData/Local/JetBrains/IntelliJIdea2021.1/log/build-log '-Djps.fallback.jdk.home=/mnt/c/Program Files/JetBrains/IntelliJ IDEA 2021.1/jbr' -Djps.fallback.jdk.version=11.0.10 -Dio.netty.noUnsafe=true '-Djava.io.tmpdir=//wsl$/Ubuntu-20.04/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/test_77f155f7/_temp_' -Djps.backward.ref.index.builder=true -Dtmh.instrument.annotations=true -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled '-Dkotlin.daemon.client.alive.path=\"C:\Users\Z004506P\AppData\Local\Temp\kotlin-idea-13948257364742160812-is-running\"' -classpath /home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jps-launcher.jar org.jetbrains.jps.cmdline.Launcher '/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/netty-buffer.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/nanoxml-2.2.3.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/maven-resolver-transport-file-1.3.3.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jna-platform.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/oro-2.0.8.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/slf4j.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/log4j.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/lz4-java-1.7.1.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jna.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/maven-resolver-provider.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/annotations.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/resources_en.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/commons-lang3-3.10.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/util.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/maven-resolver-connector-basic-1.3.3.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jps-builders-6.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/asm-all-9.1.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/forms_rt.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/guava.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jps-builders.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/zip-signer.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jdom.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/intellij-deps-fastutil-8.5.2-6.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/plexus-utils-3.3.0.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/javac2.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/qdox-2.0.0.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/commons-logging-1.2.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/trove4j.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/forms-1.1-preview.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jps-javac-extension-1.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/aether-dependency-resolver.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/http-client.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/maven-resolver-transport-http-1.3.3.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/idea_rt.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/netty-codec-http.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jps-model.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/gson-2.8.6.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-stdlib-jdk8.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/platform-api.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jasper-v2-rt.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/ant-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/java-guiForms-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/eclipse-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/eclipse-common.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/java-langInjection-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/groovy-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/groovy-constants-rt.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/maven-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/aspectj-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/gradle-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/devkit-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/javaFX-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/javaFX-common.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/javaee-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-jps-plugin.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-stdlib.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-stdlib-jdk7.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-stdlib-jdk8.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-reflect.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-plugin.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-jps-common.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/kotlin-common.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/javaee-jpa-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/javaee-appServers-websphere-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/javaee-appServers-weblogic-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/groovy-grails-jps.jar:/home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/groovy-grails-compilerPatch.jar' org.jetbrains.jps.cmdline.BuildMain 192.168.203.193 57615 867865da-6270-418c-bb35-8dcdf1591467 /home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server"
Build process started. Classpath: /home/jakub/.cache/JetBrains/IntelliJIdea2021.1/compile-server/jps-IU-211.6693.111/jps-launcher.jar
Error connecting to 192.168.203.193:57615; reason: connection timed out: /192.168.203.193:57615
io.netty.channel.ConnectTimeoutException: connection timed out: /192.168.203.193:57615
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:261)
    at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
    at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:170)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)   at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at java.base/java.lang.Thread.run(Thread.java:834)
Exiting.

ベストアンサー1

公式の指示: 間違っているか、古くなっていますか?

JetBrainsの公式説明はhttps://www.jetbrains.com/help/idea/how-to-use-wsl-development-environment-in-product.html#debugging_system_settingsWindowsファイアウォールの設定は2つの部分から成ります

(公式) ステップ 1: WSL からのトラフィックを許可する (これが正しい)

上記のリンクの最初の手順は、WSL からのすべてのトラフィックを許可する新しい受信ルールを追加することです (管理者として PowerShell を使用)。

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow

このコマンドは機能し、新しいルールを追加します。

(公式) ステップ 2: IDEA への受信トラフィックのブロックを解除する (これは誤りです)

次の手順では、IntelliJ IDEA へのトラフィックをブロックする既存のルールを削除します。

Get-NetFirewallRule | where DisplayName -ILike "idea*.exe" | Remove-NetFirewallRule

フィルター部分がwhere DisplayName -ILike "idea*.exe"何にも一致しないため、このコマンドは何も実行しません。

このプロパティは、ファイアウォール コントロール パネルの列DisplayNameに対応していると考えられます。Name

IntelliJ IDEA ルールは既に Windows ファイアウォールに含まれています

したがって、「idea*.exe」は一致しないことがわかります。

検索を次のように変更すると:

Get-NetFirewallRule | where DisplayName -ILike "IntelliJ IDEA*"

すると、シェルの出力に 4 つのルールすべてが返されます。

PS C:\Windows\system32> Get-NetFirewallRule | where DisplayName -ILike "IntelliJ IDEA*"


Name                  : TCP Query User{6288ADD6-1B2E-4BFF-9317-AEEA34194E04}C:\program files\jetbrains\intellij idea
                        community edition 2021.2\bin\idea64.exe
DisplayName           : IntelliJ IDEA Community Edition 2021.2
Description           : IntelliJ IDEA Community Edition 2021.2
DisplayGroup          :
Group                 :
Enabled               : True
Profile               : Private
Platform              : {}
Direction             : Inbound
Action                : Allow
EdgeTraversalPolicy   : DeferToUser
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 :
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

Name                  : UDP Query User{1AE9E9C6-02EF-4C65-8781-B1050740E936}C:\program files\jetbrains\intellij idea
                        community edition 2021.2\bin\idea64.exe
DisplayName           : IntelliJ IDEA Community Edition 2021.2
Description           : IntelliJ IDEA Community Edition 2021.2
DisplayGroup          :
Group                 :
Enabled               : True
Profile               : Private
Platform              : {}
Direction             : Inbound
Action                : Allow
EdgeTraversalPolicy   : DeferToUser
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 :
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

Name                  : {386E3B53-5E4D-4939-8114-74499BDA8515}
DisplayName           : IntelliJ IDEA Community Edition 2021.2
Description           : IntelliJ IDEA Community Edition 2021.2
DisplayGroup          :
Group                 :
Enabled               : True
Profile               : Public
Platform              : {}
Direction             : Inbound
Action                : Block
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 :
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

Name                  : {63ED0AB1-12B9-47F2-9810-D1D446EBF9D8}
DisplayName           : IntelliJ IDEA Community Edition 2021.2
Description           : IntelliJ IDEA Community Edition 2021.2
DisplayGroup          :
Group                 :
Enabled               : True
Profile               : Public
Platform              : {}
Direction             : Inbound
Action                : Block
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 :
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

ステップ 2: IDEA へのブロックされた受信トラフィックを削除する (右)

これら2つのパブリック受信規則を無効にし、新しく追加されたWSL受信規則を適用すると、それからIDEA は、以前は接続エラーで失敗していた Java を正しく実行できます。

次のいずれかの方法で、IDEA のこれら 2 つの受信パブリック ルールを同様に無効化/削除できます。

オプション 1: 高度なセキュリティを備えた Windows Defender ファイアウォール > 受信の規則

上の画像に示すビューで、ルールを右クリックし、パブリック プロファイルの各受信ルールに対して [ルールを無効にする] を選択します。

オプション2: PowerShellで無効にする

同じ 2 つのルールを PowerShell (管理者として) 経由で次のコマンドで無効にできます。

Get-NetFirewallProfile -Name Public | Get-NetFirewallRule | where DisplayName -ILike "IntelliJ IDEA*" | Disable-NetFirewallRule

オプション3: PowerShellで削除する

同じ 2 つのルールを、PowerShell (管理者として) で次のコマンドを使用して削除できます。

Get-NetFirewallProfile -Name Public | Get-NetFirewallRule | where DisplayName -ILike "IntelliJ IDEA*" | Remove-NetFirewallRule

これら 3 つの方法はすべて機能し、すべての Windows ファイアウォール プロファイル (ドメイン、プライベート、パブリック) を有効にすることができ、WSL2 ファイルシステムにある WSL2 プロジェクトの IDEA で Java が正しく実行されるようになりました。

アップデート: 最新バージョンでは、WSL を再起動するまで WSL2 ファイルシステムに接続する機能が「失われる」ため、最新の 2021.2 バージョンから 2021.1.3 にロールバックする必要がありました。

両方のバージョンをインストールしましたが、2021.1.3プログラムへのトラフィックを許可するようにファイアウォールルールを編集する必要がありました(奇妙なことに、名前2021.2 をファイアウォールで有効にし、パブリック プロファイル (以前はプライベート) を許可ルールに追加します。

おすすめ記事