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
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:then
chmod +x /Application/IntelliJ\ IDEA\ 14.app/Contents/MacOS/idea.sh
then edit
/Application/IntelliJ\ IDEA\ 14.app/Contents/Info.plist
and setCFBundleExecutable
toidea.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.
I contacted JetBrains support about this. The one thing they suggested was running IntelliJ from the command line, which is working for me: