'Cannot locate Agda mode binary when running Emacs GUI on OSX
Emacs (from https://emacsformacosx.com/) and Agda (via homebrew) both install gracefully. However when launching Emacs after running agda-mode setup
I receive the following error:
Warning (initialization): An error occurred while loading ‘/Users/user/.emacs’:
File is missing: Cannot open load file, No such file or directory, /Users/user/zsh:1: command not found: agda-mode
Terminal version of Emacs loads Agda-mode properly and I tried exec-path-from-shell -library without success.
My .emacs has the following content:
(package-initialize)
(load-file
(let ((coding-system-for-read 'utf-8))
(shell-command-to-string "agda-mode locate")))
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
Does anyone have the same issue / knows how to fix it or where it comes from? Thanks in advance!
Solution 1:[1]
Had the same problem on MacOS Catalina and GNU emacs. It turned out to be a path problem like @viam0Zah suggested. Here's what fixed it for me:
In the terminal, ran echo $PATH
and compared to agda-mode locate
to figure out what path is required to find agda-mode. For me, it was /Users/aransil/.cabal/bin
.
In GNU emacs, used (shell-command-to-string "echo $PATH")
to verify that the path variable is different and doesn't include /Users/aransil/.cabal/bin
.
Back in the terminal, edited ~/.zshenv
by adding the line export PATH=/Users/aransil/.cabal/bin:$PATH
Restarted GNU emacs
Solution 2:[2]
This answer is a bit late, but in case someone else has the same issue. I believe everyone is on the right track that it is a path problem. On macos, things started from the GUI don't have the full shell path. This sexpr from your .emacs
file should fix that:
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
The issue is that the fix occurs after the load-file
in your .emacs file. So the error occurs before the path is fixed. If you move that expression up to the top of the file, I think the problem will be fixed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Red Ransil |
Solution 2 | Steve |