Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to Run->Debug in Intellij Idea 2022.1, it shut's down immediately with exit code 2 #11261

Open
EirikFinvold opened this issue Apr 29, 2022 · 15 comments

Comments

@EirikFinvold
Copy link

EirikFinvold commented Apr 29, 2022

I face what seems like a similar issue as #11086 with 2.8.15 and the latest IntelliJ Idea (IntelliJ IDEA 2022.1 (Ultimate Edition) Build #IU-221.5080.210, built on April 12, 2022). Just like with the problem above it works fine running sbt run but not Idea->Run->Debug.
It works perfectly well on linux, but not on two different Windows computers.

Reproduce:

  • Create a brand new project with sbt new playframework/play-java-seed.g8
  • Open with Idea
  • Use run->debug->sbt task with "Use sbt shell" disabled
  • IntelliJ is configured with Oracle OpenJDK 11.0.14, SBT Shell use for both "project reloads" and "build".
    "Use Play 2 compiler for this project" is disabled (tried both).

When starting the debugger it builds just fine, but when it after building opens the debugger console it exits immediately:

Connected to the target VM, address: '127.0.0.1:52457', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:52457', transport: 'socket'
Process finished with exit code 2

Closing Idea and running call sbt run > test.log 2>&1 works, but maybe the first error is the problem? Output from test.log:

A subdirectory or file [info] welcome to sbt 1.6.2 (Oracle Corporation Java 11.0.14) already exists.
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 11.0.14)
[info] loading settings for project global-plugins from idea.sbt ...
[info] loading global plugins from C:\Users\Eirik.sbt\1.0\plugins
[info] loading settings for project microlog-learn-play-build from plugins.sbt ...
[info] loading project definition from C:\Users\Eirik\microlog-learn-play\project
[info] loading settings for project root from build.sbt ...
[info] set current project to microlog-learn-play (in build file:/C:/Users/Eirik/microlog-learn-play/)
[error] Expected 'error'
[error] --export-rt
[error] ^
[info] welcome to sbt 1.6.2 (Oracle Corporation Java 11.0.14)
[info] loading settings for project global-plugins from idea.sbt ...
[info] loading global plugins from C:\Users\Eirik.sbt\1.0\plugins
[info] loading settings for project microlog-learn-play-build from plugins.sbt ...
[info] loading project definition from C:\Users\Eirik\microlog-learn-play\project
[info] loading settings for project root from build.sbt ...
[info] set current project to microlog-learn-play (in build file:/C:/Users/Eirik/microlog-learn-play/)

--- (Running the application, auto-reloading is enabled) ---

[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Enter to stop and go back to the console...)

I tried SBT versions from 1.4.0->1.6.2 and also downgrading Play back to 2.8.8.

-->

Play Version

2.8.8 -> 2.8.14

API

Java 11.0.14

Operating System

Windows 10

@aumann
Copy link
Contributor

aumann commented May 4, 2022

Just wanted to let you know that we have the same issue, maybe more information helps us track down the issue. In our case, a full reboot of Windows temporarily solves the issue -- it is reappearing though, and an IntelliJ restart does not help. Really strange...

In our case run from the sbt shell starts the application without any issues.

However, using the run configuration from IntelliJ fails (both for "Run" and "Debug"). It only prints the exit code, there is no further information.

What's also strange: This is only a problem on my colleague's machine, everythings works alright for me.

Play Version

2.8.8; 2.8.15

SBT version

1.5.5; 1.6.2

Java Version

11.0.13 (Eclipse Adoptium Temurin)

Operating System

Windows 10

IntelliJ versions

2021.3; 2022.1

@mkurz
Copy link
Member

mkurz commented May 4, 2022

My guess is that this was introduced in latest IntelliJ 2022.1, maybe open a bug there? See https://youtrack.jetbrains.com/issues?q=Subsystem:%20%7BPlay%20Framework%7D

@mkurz
Copy link
Member

mkurz commented May 4, 2022

Can you confirm this is working with 2021.3?

@aumann
Copy link
Contributor

aumann commented May 4, 2022

We will check and report back, thanks for the quick reply. We had the issue in 2021.3 but that was probably still with Play 2.8.8 and is thus fixed with #11086

@mkurz
Copy link
Member

mkurz commented May 4, 2022

Yeah, it's easy to get confused, so please make sure to alway test with latest 2.8.15, thanks!

@aumann
Copy link
Contributor

aumann commented May 5, 2022

The issue is also present in IntelliJ 2021.3 (Build #IU-213.5744.223, built on November 27, 2021), using the current plugin version 2.8.15

We've also tested in 2021.3.3 (Build #IU-213.7172.25, built on March 15, 2022)

The output of the run (for 2021.3) was:

"D:\Programme\Eclipse Adoptium\jdk-11.0.13.8-hotspot\bin\java.exe" -Dfile.encoding=UTF8 -Djline.terminal=none -Dsbt.global.base=C:\Users\kim\AppData\Local\Temp\sbt-global-plugin9stub -Dsbt.log.noformat=true -Xms512M -Xmx1024M -Xss1M -Dconfig.file=conf/application.dev.conf -classpath C:\Users\kim\AppData\Roaming\JetBrains\IntelliJIdea2021.3\plugins\Scala\launcher\sbt-launch.jar xsbt.boot.Boot "project root" ~run

Process finished with exit code 2

Workaround - sbt shell is related

However, it seems that this is related to an sbt-shell running (in the sbt-shell tool window). We've just been able to reproduce this on a second machine: whenever the sbt shell is running, the app run fails with exit code 2. As soon as the sbt shell is stopped, the play application starts again.

Interesting enough, this is independent of the "use sbt for project reload/builds" settings.

=> We have a workaround - both in 2021.3.3 and 2022.1 it works when first closing the sbt shell window.

@PromanSEW
Copy link
Contributor

PromanSEW commented May 5, 2022

I have the same issue. I got it today when had to docker:publish
Also, I did not find sbt shell window, which I used to run SBT without certain command, it disappeared unexpectedly
Tasks in sbt window also do not work
Now, to start sbt shell I should open terminal and run the command which prints Process finished with exit code 2

@mkurz
Copy link
Member

mkurz commented May 5, 2022

I need to get my hands on a windows machine to test this. However, it might make sense to open a bug report in the JetBrain issue tracker (youtrack)?

@aumann
Copy link
Contributor

aumann commented May 9, 2022

One more note: it seems that whenever the sbt shell is open in IntellIiJ, even starting another sbt from powershell or git bash is not possible. Running > sbt itself immediately terminates, too.

@EirikFinvold
Copy link
Author

I have reported it to JetBrains as well:
https://youtrack.jetbrains.com/issue/IDEA-293783/Not-able-to-Run-Debug-in-Intellij-Idea-2022-1-on-Windows-it-shut

@PromanSEW
Copy link
Contributor

PromanSEW commented May 10, 2022

Moved issue to Scala:
https://youtrack.jetbrains.com/issue/SCL-20206/Not-able-to-Run-Debug-in-Intellij-Idea-2022-1-on-Windows-it-shut

@EirikFinvold
Copy link
Author

FYI, a workaround to this issue is to run the application as a "Play2 App" instead of SBT Task, and add this to JVM params: -Dsbt.server.forcestart=true

@aelfric
Copy link

aelfric commented Sep 19, 2022

Another workaround that seems to work for my team is using ~run instead of run in the Intellij run configuration.

@mkurz
Copy link
Member

mkurz commented Mar 12, 2024

Is this still a problem in IntelliJ IDEA 2023.3 on Windows?

@aumann
Copy link
Contributor

aumann commented Mar 13, 2024

I only did a very quick check - this may well be a different issue (Windows?). However, I still can't launch the play app while the sbt shell is active. I get the following error:

sbt.internal.ServerAlreadyBootingException: java.io.IOException: Could not create lock for \\.\pipe\sbt-load7156255216700723040_lock, error 5
	at sbt.internal.BootServerSocket.newSocket(BootServerSocket.java:357)
	at sbt.internal.BootServerSocket.<init>(BootServerSocket.java:296)
	at sbt.xMain$.getSocketOrExit(Main.scala:152)
	at sbt.xMain$.bootServerSocket$lzycompute$1(Main.scala:78)
	at sbt.xMain$.bootServerSocket$1(Main.scala:78)
	at sbt.xMain$.withStreams$1(Main.scala:86)
	at sbt.xMain$.run(Main.scala:123)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:59)
	at sbt.xMain.run(Main.scala:47)
	at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
	at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
	at xsbt.boot.Launch$.run(Launch.scala:149)
	at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
	at xsbt.boot.Launch$.launch(Launch.scala:159)
	at xsbt.boot.Launch$.apply(Launch.scala:44)
	at xsbt.boot.Launch$.apply(Launch.scala:21)
	at xsbt.boot.Boot$.runImpl(Boot.scala:78)
	at xsbt.boot.Boot$.run(Boot.scala:73)
	at xsbt.boot.Boot$.main(Boot.scala:21)
	at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.io.IOException: Could not create lock for \\.\pipe\sbt-load7156255216700723040_lock, error 5
	at org.scalasbt.ipcsocket.Win32NamedPipeServerSocket.<init>(Win32NamedPipeServerSocket.java:129)
	at org.scalasbt.ipcsocket.Win32NamedPipeServerSocket.<init>(Win32NamedPipeServerSocket.java:48)
	at sbt.internal.BootServerSocket.newSocket(BootServerSocket.java:351)
	... 23 more

It works if I close the sbt shell first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants