Comments (32)
@maxandersen Got. I will find a Windows laptop to test it later, thanks for your help.
from jbang-idea.
There are two issues here:
-
jbang plug-in runs it's jbang process executions in the main event loop blocking everything. It should not do that. Any failure Or long time processing a jbang call can do should not block the ide. No matter which OS.
-
figure out why when jbang called from IntelliJ is sometimes stuck.
from jbang-idea.
It works with the pb.inheritIO()
with the script mentioned above . Would it make sense to put it into the JbangCli.kt too? Could it be marked as some fix or just a workaround?
from jbang-idea.
@maxandersen I added pb.inheritIO() to JbangCli.kt, but failed to get output from process output, and I will try to fix it today. I will try https://github.com/zeroturnaround/zt-exec
from jbang-idea.
And yes ztexec does this right.
from jbang-idea.
@linux-china so much better!
I cleared my Quarkus dependencies from my laptop, took a few seconds to download them, but it is working. Any plan for the UI blocking? Could it done in background somehow?
from jbang-idea.
@nandorholozsnyak Introduce ProgressManager and Task.Backgroundable to sync dependencies asynchronously. If all good after your trial, and I will release new version.
from jbang-idea.
Yeah. At the moment the action is blocking where it should be async + show output.
But weird it never completes though. It should.
from jbang-idea.
Yeah. At the moment the action is blocking where it should be async + show output.
But weird it never completes though. It should.
Yeah I know, it is this: #19
But this newly opened is never ending, makes the IDE fully blocked and I have to close it from the Task Manager.
from jbang-idea.
@linux-china do you have an idea what could cause it?
from jbang-idea.
@nandorholozsnyak I will take a look. It happened sometime, right? Sometime success and sometime fail.
from jbang-idea.
Always fails. I mean, always kills the IDEA. I have to shutdown it from the Task Manager.
from jbang-idea.
@nandorholozsnyak could you do me a favor? Run following code on your laptop.
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 11
public class Hello {
public static void main(String... args) throws Exception {
String jbangCmd = "jbang.cmd";
ProcessBuilder pb = new ProcessBuilder(jbangCmd, "info", "classpath", "--fresh", "jbang-demo/hello.java");
Process process = pb.start();
process.waitFor();
}
}
If possible, could you change JAVA_HOME to jbr directory of IDEA_DIR and test again?
from jbang-idea.
Hey @linux-china,
First run without setting the JAVA_HOME to jbr:
X:\linux-china-jbang
λ jbang Hello.java
[jbang] Building jar...
After setting the JAVA_HOME and PATH to the jbr.
X:\linux-china-jbang
λ set | grep JAVA_HOME
JAVA_HOME=C:\Program Files\JetBrains\IntelliJ IDEA 212.4746.2\jbr
X:\linux-china-jbang
λ which java
/c/Program Files/JetBrains/IntelliJ IDEA 212.4746.2/jbr/bin/java
X:\linux-china-jbang
λ jbang Hello.java
X:\linux-china-jbang
λ
Prompt comes back, nothing is being blocked.
from jbang-idea.
Right now I'm experiencing with the script that is freezing always, and I think it only freezes with just this one specific script, I'm experimenting with the deps now, I'm assuming maybe the @pom directive kills it or the Quarkus deps, IDK yet. Here are the an example script that kills the IDEA on sync.
///usr/bin/env jbang "$0" "$@" ; exit $?
// Update the Quarkus version to what you want here or run jbang with
// `-Dquarkus.version=<version>` to override it.
//DEPS io.quarkus:quarkus-bom:${quarkus.version:2.6.0.Final}@pom
//DEPS io.quarkus:quarkus-picocli
//DEPS io.quarkus:quarkus-qute
//DEPS io.quarkus:quarkus-jackson
//DEPS commons-io:commons-io:2.11.0
//Q:CONFIG quarkus.banner.enabled=false
//Q:CONFIG quarkus.log.level=WARN
import static java.lang.System.*;
public class Hello {
public static void main(String... args) {
out.println("Hello World");
}
}
from jbang-idea.
I do not really understand, if any of the Quarkus dependencies are in the list, with the BOM without version, or without the BOM and with version, IDEA freezes and that is all, without the Quarkus dependencies, only wiht the commons-io:commons-io:2.11.0 dependency the dependencies got synced.
And yes! If the jbang-demo/hello.java
file has the same dependencies then the jbang Hello.java got stuck. Interesting! I hope it will help.
from jbang-idea.
@maxandersen your sync operation is to gradle or IDEA module?
It works on my mac laptop with sync to IDEA module.
from jbang-idea.
And on Linux too. But on Windows there are some problem with that. :/
from jbang-idea.
The most interesting stuff is that it happens only with Quarkus dependencies... I will do some other tests and will let you know about the results.
from jbang-idea.
@nandorholozsnyak what version of jbang are you running ? what does jbang version
give you ?
from jbang-idea.
I have a theory that the issue is that under windows the jbang info classpath
somehow does not close the streams properly and thus java keeps waiting for the process.
I've seen that before in other cases dealing with java process launch.
Why it happens only for Quarkus dependencies I'm not sure about - my guess will be that it has enough dependencies to trigger a flush() that you would not see for other cases with less dependencies.
@quintesse rings a bell?
from jbang-idea.
...weird though why it freezes for you inside idea but not when running the "launch jbang" script @linux-china provided....could it be a JVM difference? like intellij runs with a different jvm than the one you use on the command line?
from jbang-idea.
@nandorholozsnyak what version of jbang are you running ? what does
jbang version
give you ?
JBang version: 0.88.0
from jbang-idea.
I'm able to reproduce on the command line using what @nandorholozsnyak mentioned earlier:
And yes! If the jbang-demo/hello.java file has the same dependencies then the jbang Hello.java got stuck. Interesting! I hope it will help.
Edit: tested with both 0.87.0 and 0.88.0
from jbang-idea.
It must by an IO problem because adding pb.inheritIO()
to the code above fixes the hang.
from jbang-idea.
I think Windows might be a little bit more strict than Linux/MacOS or has smaller buffers or something. Because in the code examples I see on the Internet I think the idea is that you first handle any IO before you do a waitFor()
. In the case of the IDEA plugin this is done the other way around: it first runs waitFor()
and then handles the IO.
from jbang-idea.
The key is in what @quintesse references. We should be pumping stdin/out during run.
I have had this issue with karate test suite. Failed on windows at different times because the stdin/out was not emptied properly.
There must be a way in IntelliJ where they have mechanics to process the input/output.
from jbang-idea.
@nandorholozsnyak I built a new version with zt-exec, and could you try it on your script?
from jbang-idea.
@linux-china
Look better, IDEA does not freeze, BUT! The jbang dependency for the module is not being created.
If yes (I have to do the Sync action a few times), then all the path is wrong.
from jbang-idea.
@nandorholozsnyak my bad :( Caused by return output.split(':', ';').filter { !it.contains(".jbang") }
and it should be output.split(File.pathSeparator).filter { !it.contains(".jbang") }
I should find a Windows laptop to test. At least we fixed the process output problem on windows.
Sorry for this stupid bug, and try new build.
from jbang-idea.
I'm here to test ;)
from jbang-idea.
@linux-china works like charm. Superb enhancement! Good job.
from jbang-idea.
Related Issues (20)
- Install JBang executable if does not exist on the computer HOT 1
- when build.gradle present cannot sync dependencies
- Add options to set environment variables and working directory HOT 2
- //DEPS content assist only works on first item HOT 2
- Show more options for //DEPS assist HOT 1
- Specifying //JAVA shows wrong version in JBang panel HOT 1
- Support invoking catalogs in the Run configuration HOT 4
- Possibly invalid reference to 'NotUnderContentRootModuleInfo.project' HOT 1
- Support IDEA 2022.2 EAP HOT 1
- use private artifactory to sync deps to module HOT 3
- Plugin doesn't aknowledge JBANG_HOME
- Running JBang as a Scratch file will not set the Script file attribute properly HOT 3
- cannot create jbang script in intellij idea HOT 10
- Unable to create a JBang script from Intellij HOT 3
- Sync 'JBang DEPS to Module' fails with 'Could not execute [/Users/cer/.jbang/bin/jbang' HOT 2
- JBang not listed in project generators HOT 3
- NPE running "New/JBangScript" in IntelliJ 2022.3.3 HOT 1
- jbang edit --open=idea Test.kt doesn't work with IntelliJ 2022.3.3 HOT 5
- IDEA does not see jbang installed with scoop HOT 2
- Use `hello = Basic Hello World template` as the default option when creating a new JBang Script HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jbang-idea.