java IntelliJ 无法识别 PATH 变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15201763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 18:50:08  来源:igfitidea点击:

IntelliJ does not recognize PATH variable

javashellpathintellij-ideaenvironment-variables

提问by u6f6o

I recently tried to import an existing Gradle project, using the option "Open Project" in the startup window and the existing build.gradle file to automatically set-up the project.

我最近尝试导入现有的 Gradle 项目,使用启动窗口中的“打开项目”选项和现有的 build.gradle 文件来自动设置项目。

Right after I did this, an error message appeared in IntelliJ, saying:

就在我这样做之后,IntelliJ 中出现了一条错误消息,说:

Could not fetch model of type 'BasicIdeaProject' using Gradle installation '/Users/myUser/Tools/gradle-1.3'. Build file '/Users/myUser/IdeaProjects/myProject/database/build.gradle' line: 20 A problem occurred evaluating project ':database'. A problem occurred evaluating project ':database'. 'play' command was not found in PATH. Make sure you have Play Framework 2.0 installed and in your path

无法使用 Gradle 安装“/Users/myUser/Tools/gradle-1.3”获取“BasicIdeaProject”类型的模型。构建文件“/Users/myUser/IdeaProjects/myProject/database/build.gradle”行:20 评估项目“:database”时出现问题。评估项目“:database”时出现问题。在 PATH 中找不到“播放”命令。确保您已安装 Play Framework 2.0 并在您的路径中

As it looks like, IntelliJ complains that I did not add the play framework to my PATH variable. Although output from the shell tells sth. else:

看起来,IntelliJ 抱怨我没有将播放框架添加到我的 PATH 变量中。尽管 shell 的输出告诉了某事。别的:

echo $PATH; 
/usr/local/bin:/Users/myUser/Library/Ruby/Gems/1.8/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/Users/myUser/.yadr/bin:/Users/myUser/.yadr/bin/yadr:/Users/myUser/Tools/gradle/bin:/usr/local/Cellar/mongodb/2.2.2-x86_64//bin:/Users/myUser/Tools/groovy/bin:/Users/myUser/Tools/play-2.0

I also wrote a simple class to display the PATH variable used by IntelliJ:

我还写了一个简单的类来显示 IntelliJ 使用的 PATH 变量:

public class Playground {

    public static void main(String[] args) {

        System.out.println( System.getenv( "PATH" ));
    }
}

When I run this class, it gives me following output:

当我运行这个类时,它给了我以下输出:

/usr/bin:/bin:/usr/sbin:/sbin

As it looks like, IntelliJ completely ignore the PATH variable set in the shell. So I'd like to know how to manipulate/configure IntelliJ to recognise this PATH variable?

看起来,IntelliJ 完全忽略了 shell 中设置的 PATH 变量。所以我想知道如何操作/配置 IntelliJ 来识别这个 PATH 变量?

The shell I am using is zsh.

我使用的外壳是 zsh。

Thanks in advance

提前致谢

采纳答案by Mikita Belahlazau

Check this post: http://emmanuelbernard.com/blog/2012/05/09/setting-global-variables-intellij/The problem is that IDEA doesn't read your .zshrcfile and doesn't know about path to play. Try to set PATH variable manually in IDEA settings.

检查这篇文章:http: //emmanuelbernard.com/blog/2012/05/09/setting-global-variables-intellij/问题是 IDEA 不读取您的.zshrc文件并且不知道播放路径。尝试在 IDEA 设置中手动设置 PATH 变量。

回答by Tyrus

You can actually use "open -a [IntelliJ App]" on mac from the command line and it should pick up your path variables for your .bash_profile and/or .zshrc - better than cutting and pasting into IntelliJ IMO. Seems to be a mac only issue if I'm not mistaken.

您实际上可以从命令行在 mac 上使用“open -a [IntelliJ App]”,它应该为您的 .bash_profile 和/或 .zshrc 选择路径变量 - 比剪切并粘贴到 IntelliJ IMO 中更好。如果我没记错的话,这似乎只是 mac 的问题。