安装程序如何在Mac OSX上设置PATH变量?

huangapple go评论89阅读模式
英文:

How does installers set PATH variable on Mac OSX?

问题

我想知道Mac OSX上的Mac安装程序是如何设置PATH变量的。

以golang Mac OSX安装程序为例。从链接https://golang.org/doc/install中可以看到:

Mac OS X包安装程序

下载包文件,打开它,并按照提示进行安装Go工具。该包将Go发行版安装到/usr/local/go。

该包应该将/usr/local/go/bin目录放入您的PATH环境变量中。您可能需要重新启动任何打开的终端会话才能使更改生效。

所以,我可以在$PATH中看到/usr/local/go/bin,但它没有在.profile、.bashrc或launchd.conf中设置。

有人可以帮助我理解吗?

英文:

I'm wondering how PATH variable is set by Mac Installers on Mac OSX.

For example:

Look at golang Mac OSX Installer. From the link https://golang.org/doc/install:

> Mac OS X package installer
>
> Download the package file, open it, and follow the prompts to install
> the Go tools. The package installs the Go distribution to
> /usr/local/go.
>
> The package should put the /usr/local/go/bin directory in your PATH
> environment variable. You may need to restart any open Terminal
> sessions for the change to take effect.

So, the I can see /usr/local/go/bin in $PATH but it's not being set in .profile, .bashrc or launchd.conf.

Can anybody please help me to understand?

答案1

得分: 6

在Mac OS X中,有几种设置环境变量的方法(这里有很多讨论)。对于Go包来说,它会在/etc/paths.d目录下添加一个名为go的文件,其中包含/usr/local/go/bin。这里有一个回答另一个问题的答案,解释了一个名为path_helper的实用程序被启动,它会检查/etc/paths.d目录。

你可以使用一个叫做Pacifist的应用程序来检查Go包的内容,并查看它安装的文件。

英文:

There are a couple methods of setting environment variables in Mac OS X (lots of discussion here). In the case the Go package, it is adding a file in /etc/paths.d named go that contains /usr/local/go/bin. Here's an answer to another question explaining that a utility called path_helper is being launched and it's inspecting the /etc/paths.d directory.

You can verify this yourself by using an application called Pacifist to inspect the contents of the Go package and looking at the files it's installing.

huangapple
  • 本文由 发表于 2015年2月11日 11:44:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/28446258.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定