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

cannot create jbang script in intellij idea #73

Closed
AdityaPadhy opened this issue Oct 19, 2022 · 19 comments · Fixed by #114 or #115
Closed

cannot create jbang script in intellij idea #73

AdityaPadhy opened this issue Oct 19, 2022 · 19 comments · Fixed by #114 or #115
Assignees

Comments

@AdityaPadhy
Copy link

AdityaPadhy commented Oct 19, 2022

I installed jbang with sdk man, by default it is installed in ~/.sdkman/candidates/jbang/current

Than i installed jbang intellij idea plugin. I tried both community v2022.2.2 and ultimate v2022.2.1

Whenever i try to do file -> new -> jbang script, i get this error:
Could not execute [~/.jbang/bin/jbang, template, list] with environment {NO_COLOR=true}. Error=2, No such file or directory

Note: my jbang installation is working fine, i can run jbang files from command line.

in vscode there an option to set as jbang home, probably that kind of setting would be required. Could you please check.

@linux-china linux-china self-assigned this Oct 25, 2022
@maxandersen
Copy link
Contributor

Are you really seeing "~/.jbang/bin/jbang" in the error?

Asking as ~ should not be in there.

@ledinscak
Copy link

ledinscak commented Nov 19, 2022

Same here, jbang installed by sdkman, working fine.
But same error when trying to create script in IDEA.
I get full path of my $HOME in error message by the way.

@linux-china
Copy link
Contributor

@ledinscak @AdityaPadhy I added sdkman auto detection. Could you install attachment and have a test?

jbang-idea-plugin-0.23.1.zip

@maxandersen
Copy link
Contributor

Got the pr/branch so can build it myself rather than running arbitrary zips?

And shouldn't need custom sdkman detection should we ? Should just search the PATH and it shouldn't matter what installed it ?

@AdityaPadhy
Copy link
Author

After installing the zip i have this error:

java.lang.NullPointerException
at dev.jbang.idea.actions.CreateFromTemplateAction.actionPerformed(CreateFromTemplateAction.kt:68)
at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:315)
at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:294)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:337)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:294)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$performAction$4(ActionMenuItem.java:293)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:227)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.performAction(ActionMenuItem.java:286)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$new$1(ActionMenuItem.java:78)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:513)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:75)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:118)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:42)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:918)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:766)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:450)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:449)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:624)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:447)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:493)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

@linux-china
Copy link
Contributor

@AdityaPadhy Failed to execute jbang init --template hello --force Demo.java. Could you see the Init from JBang templates dialog? and what are your template name and Script name? Thanks.

@maxandersen
Copy link
Contributor

@linux-china can you push the proposed changes to a Pull request ? I think we really should simplify the jbang lookup to purely be in JBANG_HOME, PATH and ~/.jbang in that order and nothing else.

@AdityaPadhy
Copy link
Author

AdityaPadhy commented Nov 24, 2022

should not be there a setting just like maven home in intellij preferences, it should be easy to override as per need.

@maxandersen
Copy link
Contributor

Yes. That too. My point is that we should make it pick up "safe jbang" locations so it will just work for most cases but shouldn't be trying to guess which if possible multiple jbang sdkman installations user wants to use.

@linux-china
Copy link
Contributor

Now the plugin supports JBANG_HOME env variable, and you can set up JBang install directory. Please refer #66

@msangel
Copy link

msangel commented Aug 29, 2024

same error here, also installed via SDKMAN

idea details:

IntelliJ IDEA 2024.2.1 (Ultimate Edition)
Build #IU-242.21829.142, built on August 28, 2024
Linux 6.8.0-41-generic
Non-Bundled Plugins:
  dev.jbang.intellij.JBangPlugin (0.24.6)
Current Desktop: XFCE

jbang details:

✔ swift3:~> jbang --version
0.117.1
✔ swift3:~> type jbang
jbang is hashed (/home/msangel/.sdkman/candidates/jbang/current/bin/jbang)
✔ swift3:~> echo $JBANG_HOME
/home/msangel/.sdkman/candidates/jbang/current
✔ swift3:~> 

But still error:
image

@msangel
Copy link

msangel commented Aug 29, 2024

Found the cause:
image

Still not see other way of fixing it other then run idea only from terminal...

@linux-china
Copy link
Contributor

@msangel I will take a look, maybe we can skip jbang script invoke and call java directly.

@maxandersen
Copy link
Contributor

Calling directly with Java does not make sense to me. If you have jbang.jar located to call with java directly you also have the corresponding jbang script which you will need as it does the actual proper execution and handle piping and command line escaping and other important aspects.

@maxandersen
Copy link
Contributor

The plugin should simply look in default locations by default AND allow user to specify explicit location for the cases where user doesn't run with jbang etc. configured in its global environment.

@msangel
Copy link

msangel commented Sep 10, 2024

Upviting comment above. First it should try default location, then try sdkman location (that is also static and constant and should cover problem case we have and should be fast to implement), then simply ask for explicit plugin option where user might specify location.

@linux-china
Copy link
Contributor

@maxandersen Is it possible to attach jbang.jar for the plugin? Now jbang.jar is just 7.3M

@maxandersen
Copy link
Contributor

Imo Just ask for location if not found in path, env nor default location - (sdkman is not a valid default; anymore than brew, choco etc) but can suggest it as the configured location.

Also offer to download it like maven/Gradle plugins and having default does - jbang has a default download and install location. i don't see an apparent advantage to bundle it and have it go out of date.

@fbricon
Copy link
Contributor

fbricon commented Sep 15, 2024

#114 fixes it for me

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