求助:mac下emacs的路径找不到了

谷歌了半天,没找到办法。求助:

mac系统,GNU Emacs 28.1.91 (build 1, aarch64-apple-darwin21.6.0, Carbon Version 165 AppKit 2113.6) of 2022-08-24

之前很好,今天升级一下brew upgrade,然后brew竟然升级emacs了。

再然后,想doom sync一下,发现不行了。

./bin/doom sync Error: failed to run Emacs with command ‘emacs’

Are you sure Emacs is installed and in your $PATH?

测试了网上几种方法,皆无效,好像是路径问题。求指点!

brew的信息如下: Downloading https://raw.githubusercontent.com/railwaycat/homebrew-emacsmacpo Already downloaded: /Users/chinhant/Library/Caches/Homebrew/downloads/8a6c12e323fded340e400b297b7cf56254dc256768d95a99b74d9d2b0cb3806a–multi-tty-27.diff ==> Cloning Bitbucket Updating /Users/chinhant/Library/Caches/Homebrew/emacs-mac–git From https://bitbucket.org/mituharu/emacs-mac 504adeb5c9…6e6d2e0c27 work → origin/work ==> Checking out branch work Already on ‘work’ Your branch is behind ‘origin/work’ by 80 commits, and can be fast-forwarded. (use “git pull” to update your local branch) HEAD is now at 6e6d2e0c27 Merge branch ‘mac’ into work

tell application id "org.gnu.Emacs" to activate

重新 brew link 一下,需要的话用–overwrite

1 个赞

謝謝,原來brew还有这个link的一步,这个可以解决;

brew link --overwrite emacs-mac

Emacs-plus 有更好的解决方案了:

osascript -e 'tell application "Finder" to make alias file to posix file "/opt/homebrew/opt/emacs-plus@29/Emacs.app" at POSIX file "/Applications"'

Emacs-mac 应该也能用。

1 个赞

应该提个PR直接集成到emacs-plus的build步骤里。另外这个解决不了楼主提到的路径问题,也就是命令行的PATH中找不到。

我就是从 emacs-plus 的 PR 里学来的这个技巧。

因为 macOS 的 symlink 和 AppleScript 的 alias 不一样,直接 brew link 的话会导致 Spotlight/Alfred 无法索引到 Emacs.app。

终端下的 $PATH 我没配置过,安装 emacs-plus 然后运行上述 AppleScript 就完事儿了,终端下也能用,不需要再额外配置什么。