Running JHipster Gradle task from Intellij IDEA

2019-01-25 22:07发布

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

2条回答
戒情不戒烟
2楼-- · 2019-01-25 22:55

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.

查看更多
祖国的老花朵
3楼-- · 2019-01-25 22:59

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"
查看更多
登录 后发表回答