Skip to content
TheChatArchiveThe Chat Archive
Amazon Novaamazon.nova-pro-v1:0· AmazonHugging Face LMArena Human Preference 140K

When I start emacs from the terminal, where I have zsh with PATH defined also to…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-sonnet-4-20250514-thinking-32k’s answer.
  1. 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

  2. Amazon Nova 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 PATH when started in any manner, you can add the directory to the exec-path within your Emacs configuration. The exec-path is a list of directories that Emacs searches for executables.

    Here’s how you can do it:

    1. 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")
      
    2. Ensure PATH is updated:

      You can also set the PATH environment variable directly within Emacs to make sure it includes ~/.local/bin:

      (setenv "PATH" (concat (getenv "PATH") ":~/.local/bin"))
      
    3. Combine both for robustness:

      It’s a good practice to update both exec-path and the PATH environment 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/bin regardless 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/bin whether started from the terminal or via a keyboard shortcut.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.