我使用Homebrew安装了一个包(qt),现在想要修改源代码并重新构建该软件。但是我好像找不到源代码的位置。brew --cache
返回的目录不存在,qt的源代码也不在/usr/local/Cellar中。我是否漏掉了什么?Homebrew在构建完应用之后会移除源代码吗?
我使用Homebrew安装了一个包(qt),现在想要修改源代码并重新构建该软件。但是我好像找不到源代码的位置。brew --cache
返回的目录不存在,qt的源代码也不在/usr/local/Cellar中。我是否漏掉了什么?Homebrew在构建完应用之后会移除源代码吗?
Homebrew仅保留二进制文件。如果您的Homebrew缓存目录(通常位于/Library/Caches/Homebrew
,但可以使用brew --cache
找到,如您所指出)已被移动或删除,则需要重新获取源代码。您可以使用brew fetch qt
仅获取源代码。
如果你只得到了源代码包,可能会缺少配方中包含的补丁,而不是你当前运行的二进制文件的确切源代码。为了获取应用了补丁的源代码树,可以执行以下操作:
brew unpack --patch <formula>
以下是man页面的内容:
unpack [--git|--patch] [--destdir=path] formulae
Unpack the source files for formulae into subdirectories of the
current working directory. If --destdir=path is given, the sub-
directories will be created in the directory named by <path>
instead.
If --patch is passed, patches for formulae will be applied to
the unpacked source.
If --git is passed, a Git repository will be initalized in the
unpacked source. This is useful for creating patches for the
software.
/Library/Caches...
而不是~/Library/Caches...
,以防对任何人有所帮助! - taber