When I start emacs from the terminal, where I have zsh with PATH defined also to…
- User
When I start emacs from the terminal, where I have zsh with PATH defined also to ~/.local/bin, my elisp macro - calling a program localted in ~/.local/bin - works. When I start emacs by a keyboard shortcut, the program is not found
Assistant
When you start Emacs from the terminal, it inherits the environment variables, including
PATH, from your shell (zsh in your case). However, when you start Emacs using a keyboard shortcut or from a desktop environment, it doesn't necessarily inherit the same environment variables.To ensure that Emacs has the correct
PATHwhen started in any manner, you can add the directory to theexec-pathwithin your Emacs configuration. Theexec-pathis a list of directories that Emacs searches for executables.Here’s how you can do it:
-
Add the directory to
exec-path:Add the following to your Emacs configuration file (usually
~/.emacs,~/.emacs.d/init.el, or similar):(add-to-list 'exec-path "~/.local/bin") -
Ensure
PATHis updated:You can also set the
PATHenvironment variable directly within Emacs to make sure it includes~/.local/bin:(setenv "PATH" (concat (getenv "PATH") ":~/.local/bin")) -
Combine both for robustness:
It’s a good practice to update both
exec-pathand thePATHenvironment variable:(let ((local-bin-dir "~/.local/bin")) (add-to-list 'exec-path local-bin-dir) (setenv "PATH" (concat (getenv "PATH") ":" local-bin-dir)))
By doing this, you ensure that Emacs will be able to find the programs in
~/.local/binregardless of how it is started.Example Configuration
Here’s a complete example that you can add to your Emacs init file:
;; Add ~/.local/bin to exec-path and PATH (let ((local-bin-dir "~/.local/bin")) (add-to-list 'exec-path local-bin-dir) (setenv "PATH" (concat (getenv "PATH") ":" local-bin-dir))) ;; Your other Emacs configurations...After adding this to your init file, restart Emacs, and it should be able to find the programs in
~/.local/binwhether started from the terminal or via a keyboard shortcut.-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.