【问题标题】:Error executing programs/compiling inside IntelliJ, no errors in command line在 IntelliJ 中执行程序/编译时出错,命令行中没有错误
【发布时间】:2012-09-29 08:15:51
【问题描述】:

我最近买了一台 Macbook Air,它现在正在运行 Mountain Lion,但我在运行公司的项目时遇到了一些问题,唯一在工作中使用 mac 的人在他的 Macbook Pro 上运行 Lion,他没有这样的问题。 正如标题所说,在命令行上编译项目没有问题,但是当我尝试在 IntelliJ 中编译它时出现此错误

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (requireJS-Optimizer) on project MarfeelTouch: Command execution failed. Cannot run program "node" (in directory "/Users/pedrompg/Documents/Marfeel/MarfeelTouch"): error=2, No such file or directory -> [Help 1]

当我从命令行编译它并尝试运行程序时也会出现问题

Caused by: java.util.concurrent.ExecutionException: java.io.IOException: Cannot run program "phantomjs" (in directory "/Users/pedrompg/Documents/Tenants/vhosts/discoverint"): error=2, No such file or directory
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:232) ~[na:1.6.0_35]
    at java.util.concurrent.FutureTask.get(FutureTask.java:91) ~[na:1.6.0_35]
    at com.marfeel.pressSystem.impl.SectionPressImpl.getAllItemsFromSectionFeeds(SectionPressImpl.java:137) ~[MarfeelPressSystem-1.0.jar:na]
    ... 29 common frames omitted

我似乎无法从项目内部运行任何命令行程序

这就是我们 phantomJS 的调用方式:

private Process buildProcess() throws IOException {
        Process process;
        String[] invocationCmd = getInvocationCmd();

        if (executionDirectory != null) {
            if (LOG.isDebugEnabled()) {
                LOG.info("Invoking PhantomJS with {} in {}.", Arrays.toString(invocationCmd), executionDirectory);
            }

            process = Runtime.getRuntime().exec(invocationCmd, null,
                    new File(executionDirectory));
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.info("Invoking PhantomJS with {} in {}.", Arrays.toString(invocationCmd));
            }

            process = Runtime.getRuntime().exec(invocationCmd, null);
        }

        return process;
    }

getInvocationCmd() 返回以下数组

[phantomjs,--load-images=no,--disk-cache=yes,--max-disk-cache-size=1048576,/Users/pedrompg/Documents/Marfeel/MarfeelHub/target/webapp/WEB-INF/classes/whiteCollar.js,marca/marca.js,http://www.marca.com/]

不知道我是否留下任何相关信息 我们在项目上使用 Maven、tomcat 7、nodeJS、phantomJS 1.5、nginx 1.2.4、java 1.6.0_35

希望有人能提供帮助,我真的很担心这个问题,已经浪费了 2 天时间来解决这个问题。

提前致谢

【问题讨论】:

    标签: java intellij-idea osx-mountain-lion ioexception


    【解决方案1】:

    当您使用 Mac 时,这很可能是与环境相关的问题。请注意,Mac GUI 应用程序不继承终端环境变量,因此如果您调整了PATH 变量并且命令可以从终端运行,当您尝试从其他应用程序运行时它将无法正常工作。

    请参阅relatedquestions,了解有关此 Mac 功能的信息。注意second link,Mountain Lion 对环境变量有不同的行为。

    验证是否存在这种情况和解决问题的最简单方法是从终端运行 IntelliJ IDEA:

    open -a /Applications/IntelliJ\ IDEA\ 11.app/
    

    这样终端环境将被传递给 IDEA,您可以从终端运行的命令也将在 IntelliJ IDEA 中运行。

    【讨论】:

    • 天哪,你救了我的命!!!如果可以的话,我会支持你,但仍然需要 +5 代表才能做到这一点。
    猜你喜欢
    • 2013-07-11
    • 1970-01-01
    • 2018-07-21
    • 1970-01-01
    • 2016-08-31
    • 2016-07-08
    • 2010-12-02
    • 1970-01-01
    • 2011-08-18
    相关资源
    最近更新 更多