I have a problem with setting up rust-playground on Emacs.
I installed rust-playground on Emacs 25.0.93 of Macbook Pro.
When I run rust-playground, the following error happens.

enter image description here

rustc /Users/hirokinoguchi/.emacs.d/rust-playground/at-2017-05-16-150310/snippet.rs -o snippet && 

/bin/bash: rustc: command not found

Compilation exited abnormally with code 127 at Tue May 16 15:03:12

I can run rustc command on bash on Emacs.

enter image description here

Maybe I need to set up rustc's PATH in a elisp file.

Could you give me some advice?

I'd appreciate your help.

  • Take a look at exec-path-from-shell. May 16, 2017 at 8:05
  • You can customize variable M-x customize-variable rust-playground-bin. By default it has value rustc for your case just set it as /usr/local/bin/rustc. But more right way described in the answer below, you should use PATH in Emacs. Jun 17, 2017 at 13:43

1 Answer 1


Even though you've got it in your shell, it looks as though you've not got /usr/local/bin in the PATH environment variable for your Emacs. You could verify this by doing M-x getenv PATH. There might be a better way, but I use a little bit of code like the following in my Emacs init file:

(defun add-to-path (dir)
 "Add DIR to PATH environment variable and Emacs' `exec-path' list."
  (setenv "PATH" (concat dir ":" (getenv "PATH")))
  (push dir exec-path))

(add-to-path "/usr/local/bin")

This adds paths to both the environment so that they'll be inherited by external processes run by Emacs, and to ensure that Emacs can find binaries in these directories.

  • I wrote the code above in the init.el, but I face with with same error.
    – Hiroki
    May 16, 2017 at 6:45
  • Have you evaluated the new code or restarted your Emacs? What value does M-x getenv give for PATH?
    – stevoooo
    May 16, 2017 at 6:54
  • Thank you for your advice! When I M-x getenv, "/usr/local/bin/rustc:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9:" appears
    – Hiroki
    May 16, 2017 at 7:03
  • Ah, it's "/usr/local/bin" (without the rustc) that you need to add to the path. The PATH environment variable specifies a list of directories in which the shell will look for programmes to run.
    – stevoooo
    May 16, 2017 at 7:13
  • Could you tell me how to fix "/usr/local/bin/rustc:" to "/usr/local/bin/"?
    – Hiroki
    May 17, 2017 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.