本文介绍了路径在launchd.conf以外的地方设置,我不知道在哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于如何为用户会话(不仅仅是终端)中的所有程序设置PATH的问题已经解决.因此,我更改了/etc/launchd.conf和/etc/paths,只是为了确保一切正常.但是,启动Terminal时,我仍然得到与预期不同的PATH envar(我完全不确定如何从另一个应用程序测试PATH.)

The question of how to set PATH for all programs in a user session (not just Terminal) has come and been addressed. So I changed both /etc/launchd.conf AND /etc/paths, just to make sure everything was ok. However, I am still getting a different PATH envar when I launch Terminal than what I'm expecting (I'm not at all sure how to test PATH from another application.)

这是/etc/launchd.conf中的内容:

Here's what's in /etc/launchd.conf:

setenv PATH /sw/bin:/sw/sbin:/sw/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11/bin:/opt/local/bin:/opt/local/sbin

这是/etc/paths中的内容:

Here's what's in /etc/paths:

.
$HOME/bin
/sw/bin
/sw/sbin
/sw/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

在/etc/paths.d/中加上几个文件:

Plus a couple of files in /etc/paths.d/:

X11:

/usr/X11/bin

opt:

/opt/local/bin
/opt/local/sbin

现在,当我启动一个新的终端时,我会得到:

Now, what I get when I launch a fresh Terminal is:

miishka:~ tamara$ echo $PATH
 /usr/bin:/bin:/usr/sbin:/sbin:.:/Users/tamara/bin:/sw/bin:/sw/sbin:/sw/local/bin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/opt/local/sbin
miishka:~ tamara$ 

我已经检查了.bashrc和.bash_profile,没有.profile,并且已经检查了/etc/profile和/etc/bashrc,并且没有一个碰到PATH envar.

I've checked my .bashrc and .bash_profile, I have no .profile, and I've checked /etc/profile and /etc/bashrc and NONE of them touch the PATH envar.

我很沮丧.

推荐答案

man path_helper

这件事使我发疯.我使用zsh,并在/etc/zshenv中找到了它.

This thing drove me crazy. I use zsh, and in /etc/zshenv i found it.

# system-wide environment settings for zsh(1)
if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

我认为

path_helper(8)实际上有一个有用的目的.苹果公司通常的超模糊系统管理员信息否定了它.即使您使用的是Macports,也可以在/etc的Shell初始化文件中的path_helper(8)中查找.这可能会有帮助.

path_helper(8) actually has a useful purpose, I think. It's negated by the usual ultra vague sysadmin info from apple. look for path_helper(8) in your shell init file, in /etc, even if you are using macports, like I am. That might help.

否则,您可以尝试在以下环境中设置环境:

Otherwise, you can try setting environment in:

 /etc/launchd.conf

但是,当然,手册页不是确定的. http://developer.apple.com 是很好的文档,但是通常我想要更好的手册页,而不是精确的内存位置.

But of course, the man page is not definitive. http://developer.apple.com is excellent documentation, but usually I want better man pages, not precise memory locations.

最后,您可以在登录窗口上将其设置为:

Finally, you can set them on on the loginwindow which reads:

 ~/.MacOSX/environment.plist

现在,对我来说,有几种方法可以做到这一点似乎很奇怪,但是...好吧,这很奇怪.他们做了一个体面的init替代者,这是一个统治所有人的过程,但是不,很多工作都在它之外进行.祝你好运.您应该可以使用以下方法之一将$ VAR放入gui中.

Now, to me, it seems odd to have several ways to do this, but... well hell, it is odd. They made a decent init replacement, it is to be the one process to rule them all, but nope, many jobs get run outside of it. Good luck. You should be able to get a $VAR into your gui using one of these methods.

啊, http://developer.apple.com/library/mac/#qa/qa1067/_index.html .

OSX具有各种会话和域.确切地说,来自

OSX has various sessions and domains. To be precise, from

 man launchctl

会话:

域:

阅读时很有意义.

U.发射总是得到我.

Ugh. launchd always gets to me.

https://serverfault.com/questions/16355/如何在OS-x上设置全局路径/277034#277034

再次声称/etc/launchd.conf是文件获取路径的位置.

Again alleges that /etc/launchd.conf is where files get the path.

所以我跑了

 opensnoop -g -c -f /etc/launchd.conf

并打开Terminal,iterm,safari,keychain ... nada.他们都没有打开该文件.

and opened Terminal, iterm, safari, keychain... nada. none of them opened that file.

但是,在观看了Google视频启动后,我就跑了

However, after watching the google video on launchd i ran

 launchctl export 

向我展示

PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;
TMPDIR="/var/folders/YH/YHFe3+5RHmuxft5hr1XZTk+++TI/-Tmp-/"; export TMPDIR;
SHELL="/opt/local/bin/zsh"; export SHELL;
HOME="/Users/kb"; export HOME;
USER="kb"; export USER;
LOGNAME="kb"; export LOGNAME;
DISPLAY="/tmp/launch-dcQkBh/org.x:0"; export DISPLAY;
SSH_AUTH_SOCK="/tmp/launch-czhyqj/Listeners"; export SSH_AUTH_SOCK;
Apple_PubSub_Socket_Render="/tmp/launch-TI7lbI/Render"; export Apple_PubSub_Socket_Render;



sudo launchctl export 

将我的上下文更改为系统上下文,而不是我作为用户的Aqua上下文返回

which changes my context to the System context, instead of my Aqua context as a user, returned

PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;

因此,上下文确实很重要,换句话说,就像命令在其中运行的会话一样重要.

So the context really does matter, in other words, as does the session a command is run in.

此工具的文档(此init替代品)是apple中最重要的守护程序,一个用来控制所有这些守护程序的守护程序,非常烦人.小便.较差的.

Documentation for this tool, this init replacement, the most important daemon in apple, the one daemon to rule them all, is piss poor. Piss. Poor.

这篇关于路径在launchd.conf以外的地方设置,我不知道在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 06:12