Problem
Executing a Gradle task as an exec trying to run yarn in the following way:
build.gradle
tasks.register('yarn', Exec) {
commandLine 'yarn'
}
This runs from a zsh command line, but fails when run from IntelliJ IDEA, with the following error:
* What went wrong:
Execution failed for task ':yarn'.
> A problem occurred starting process 'command 'yarn''
Cause: error=2, No such file or directory
Resolution
GUI apps and terminal apps typically have a different set of environment variables on macOS (it's an Apple system limitation). If you start IntelliJ IDEA from the terminal per https://intellij-support.jetbrains.com/hc/en-us/articles/360011901879-How-to-start-IDE-from-the-command-line, it should have the same environment in its built-in Terminal.
See also https://stackoverflow.com/a/26586170/104891 for the ways to set env variables on macOS so that they are the same for all the apps.
Try running /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea instead. Double-clicking this idea app via the Finder or using Terminal will fix the issue.
Another option is to create the command line launcher: Tools | Create Command-line Launcher.
If you are using Toolbox, it provides a way to generate the command launcher automatically.
See also:
https://stackoverflow.com/questions/7836492/command-line-intellij-on-mac-os-x
Comments
0 comments
Please sign in to leave a comment.