Running JHipster Gradle task from Intellij IDEA

扶醉桌前 提交于 2019-11-28 01:53:47

问题


This error happens when I run with Gradle through from Intellij IDEA.. but from console everything works fine... someone knows why?

Executing external task 'run --stacktrace'... :compileJava UP-TO-DATE :compileScala UP-TO-DATE :bower FAILED

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':bower'.

Caused by: java.io.IOException: Cannot run program "bower" (in directory "/Users/eduardo/Development/projects/jhipster"): error=2, No such file or directory


回答1:


I contacted JetBrains support about this. The one thing they suggested was running IntelliJ from the command line, which is working for me:

open -a "/Applications/IntelliJ IDEA 15.app"



回答2:


At a guess, you are running IntelliJ on OSX, maybe with a brew install of bower?

Recent versions of OSX (at least 10.10.1) don't let you easily set the PATH for graphical applications (launchctl seems to have a bug in regards to PATH). Combined with there being no way to modify the current environment PATH for launching subprocesses in Java, this results in being unable to find the bower executable. A Complete rundown of the root problem can be seen here (Setting the environment for ProcessBuilder), but essentially IntelliJ must have your PATH set correctly in order for non standard PATHs to be searched.

My solution for now is a complete hack taken from https://apple.stackexchange.com/a/51737 - essentially, create a wrapper script:

create /Application/IntelliJ\ IDEA\ 14.app/Contents/MacOS/idea.sh with contents of:

#!/bin/sh

. ~/.bash_profile

logger "`dirname \"$0\"`/idea"

exec "`dirname \"$0\"`/idea" $@

then chmod +x /Application/IntelliJ\ IDEA\ 14.app/Contents/MacOS/idea.sh

then edit /Application/IntelliJ\ IDEA\ 14.app/Contents/Info.plist and set CFBundleExecutable to idea.sh

lastly, run /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/IntelliJ\ IDEA\ 14.app

It's a hack, but it works... and until Apple fixes launchctl, it's the only solution I've come up with.



来源:https://stackoverflow.com/questions/29573526/running-jhipster-gradle-task-from-intellij-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!