我正在运行IntelliJ 13(在OS X Yosemite上)并尝试让Go IDEA plugin正常工作。当我调试应用程序以试图找出问题所在时,我发现由于某种原因,运行的从属IDEA让我的环境变好了。
通常,当尝试运行涉及go
实用程序的任何内容时,会抛出异常。该插件将通过环境变量{/ p>执行go <args>
来执行命令
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(command, goEnv, new File(projectDir));
如果我将go
命令更改为go
二进制文件的完整路径,则一切正常。然而,在调试时,我不必更改路径,它仍然成功。
该插件有一个action which prints out the environment,可以调用System.getenv()
GoToolWindow toolWindow = this.getGoToolWindow(project);
toolWindow.showAndCreate(project);
toolWindow.clearConsoleView();
String[] sysEnv = GoSdkUtil.convertEnvMapToArray(System.getenv());
toolWindow.printNormalMessage(String.format("%s -> %s%n", "Project dir", projectDir));
for (String env : sysEnv) {
toolWindow.printNormalMessage(String.format("%s%n", env));
}
正常运行IDEA时,输出:
Project dir -> /Users/lander/Development/downloader
SHELL=/bin/zsh
TMPDIR=/var/folders/6y/xxqr1vqn6q7c_ttvdgjt7p1w0000gn/T/
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PATH=/usr/bin:/bin:/usr/sbin:/sbin
XPC_FLAGS=0x0
USER=lander
HOME=/Users/lander
XPC_SERVICE_NAME=com.jetbrains.intellij.43484
LOGNAME=lander
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.tV9zH4QXK4/Render
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.BCyPknIo2V/Listeners
调试插件时:
Project dir -> /Users/lander/IdeaProjects/gotest
ZSH=/Users/lander/.oh-my-zsh
com.apple.java.jvmMode=client
GREP_OPTIONS=--color=auto --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
GOROOT=/usr/local/opt/go/libexec
XPC_FLAGS=0x0
JAVA_MAIN_CLASS_14389=com.intellij.idea.Main
LOGNAME=lander
GREP_COLOR=1;32
ZSH_TMUX_TERM=screen
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.BCyPknIo2V/Listeners
OLDPWD=/Applications/IntelliJ IDEA 13.app/Contents/bin
SHELL=/bin/zsh
LC_CTYPE=
TMPDIR=/var/folders/6y/xxqr1vqn6q7c_ttvdgjt7p1w0000gn/T/
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/texbin:/Users/lander/go/bin
VERSIONER_PYTHON_VERSION=2.7
GOPATH=/Users/lander/go
LESS=-R
USER=lander
com.apple.java.jvmTask=CommandLine_Manual.java
ZSH_TMUX_AUTOSTARTED=true
PAGER=less
HOME=/Users/lander
XPC_SERVICE_NAME=0
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.tV9zH4QXK4/Render
LSCOLORS=Gxfxcxdxbxegedabagacad
_ZSH_TMUX_FIXED_CONFIG=/Users/lander/.oh-my-zsh/plugins/tmux/tmux.extra.conf
VERSIONER_PYTHON_PREFER_32_BIT=no
差异的原因是什么?
答案 0 :(得分:0)
根据JetBrains employee,这是因为slave实例是在运行的外部脚本给出的环境下启动的。父进程中的插件不应调用System.getenv()
,而应使用EnvironmentUtil
。