Giter VIP home page Giter VIP logo

Comments (32)

linux-china avatar linux-china commented on July 19, 2024 1

@maxandersen Got. I will find a Windows laptop to test it later, thanks for your help.

from jbang-idea.

maxandersen avatar maxandersen commented on July 19, 2024 1

There are two issues here:

  1. 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.

  2. figure out why when jbang called from IntelliJ is sometimes stuck.

from jbang-idea.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024 1

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.

linux-china avatar linux-china commented on July 19, 2024 1

@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.

maxandersen avatar maxandersen commented on July 19, 2024 1

And yes ztexec does this right.

from jbang-idea.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024 1

@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?

image

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024 1

@nandorholozsnyak Introduce ProgressManager and Task.Backgroundable to sync dependencies asynchronously. If all good after your trial, and I will release new version.

Snip20220207_74

jbang-idea-plugin-0.16.0.zip

from jbang-idea.

maxandersen avatar maxandersen commented on July 19, 2024

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.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

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.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

@linux-china do you have an idea what could cause it?

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

@nandorholozsnyak I will take a look. It happened sometime, right? Sometime success and sometime fail.

from jbang-idea.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

Always fails. I mean, always kills the IDEA. I have to shutdown it from the Task Manager.

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

@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.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

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.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

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.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

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.

linux-china avatar linux-china commented on July 19, 2024

@maxandersen your sync operation is to gradle or IDEA module?

It works on my mac laptop with sync to IDEA module.

image

from jbang-idea.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

And on Linux too. But on Windows there are some problem with that. :/

from jbang-idea.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

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.

maxandersen avatar maxandersen commented on July 19, 2024

@nandorholozsnyak what version of jbang are you running ? what does jbang version give you ?

from jbang-idea.

maxandersen avatar maxandersen commented on July 19, 2024

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.

maxandersen avatar maxandersen commented on July 19, 2024

...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 avatar nandorholozsnyak commented on July 19, 2024

@nandorholozsnyak what version of jbang are you running ? what does jbang version give you ?

JBang version: 0.88.0

from jbang-idea.

quintesse avatar quintesse commented on July 19, 2024

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.

quintesse avatar quintesse commented on July 19, 2024

It must by an IO problem because adding pb.inheritIO() to the code above fixes the hang.

from jbang-idea.

quintesse avatar quintesse commented on July 19, 2024

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.

maxandersen avatar maxandersen commented on July 19, 2024

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.

linux-china avatar linux-china commented on July 19, 2024

@nandorholozsnyak I built a new version with zt-exec, and could you try it on your script?

jbang-idea-plugin-0.15.1.zip

from jbang-idea.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

@linux-china
Look better, IDEA does not freeze, BUT! The jbang dependency for the module is not being created.
image

If yes (I have to do the Sync action a few times), then all the path is wrong.

image
image

from jbang-idea.

linux-china avatar linux-china commented on July 19, 2024

@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.

jbang-idea-plugin-0.15.1.zip

from jbang-idea.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

I'm here to test ;)

from jbang-idea.

nandorholozsnyak avatar nandorholozsnyak commented on July 19, 2024

@linux-china works like charm. Superb enhancement! Good job.

from jbang-idea.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.