Emacs is ignoring my path when it runs a compile command

后端 未结 8 1661
盖世英雄少女心
盖世英雄少女心 2020-12-05 11:24

I\'m trying to get a compile command (rake cucumber) to run with a specific ruby version on my Mac OS X system, I use rvm to do this currently in the terminal. My ~/.MacOSX/

8条回答
  •  Happy的楠姐
    2020-12-05 12:28

    A small modification to the solution by sanityinc (couldn't find a way to enter it in the comments above -- is that just me?)

    • I use -l option to the shell to force a login shell (which reads .profile or .bash_profile), rather than an interactive shell (which only reads .bashrc).
    • I do some string trimming on the returned path (as inspection shows a newline sneaking in).

    Modified code:

    (defun set-exec-path-from-shell-PATH ()
      (let ((path-from-shell 
          (replace-regexp-in-string "[[:space:]\n]*$" "" 
            (shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
        (setenv "PATH" path-from-shell)
        (setq exec-path (split-string path-from-shell path-separator))))
    (when (equal system-type 'darwin) (set-exec-path-from-shell-PATH))
    

提交回复
热议问题