After some research, I was able to solve it by adding this to my init.el:
(define-key rust-mode-map (kbd "C-r") 'my-cargo-run))
(defun my-cargo-run ()
"Build and run Rust code."
(run-win (display-buffer (get-buffer "*Cargo Run*") nil '...
I had very similar problem. I use OSX and both cargo and rustc weren't in exec-path. Because I see you have /Users path - I assume u run emacs on OSX too.
My solution was exec-path-from-shell plugin. I added to my init.el something like this:
(if (eq system-type 'darwin)
The "best" way? Dunno. Define your criteria for "best". Looks OK to me, FWIW.
But I would probably just do this:
(define-key 'rust-mode-map ";" (lambda () ...))
That assumes the mode map is rust-mode-map. Oh, and I would also probably name the command, instead of using an anonymous function -- makes it easier to work with.
But it probably doesn't ...
Hot diggity darn, but minutes later I discovered a crate for that. For future people landing on this question, all I had to do was run
cargo install cargo-script
and bam you'll be off and org-babel-ing. If you've got Cargo.el installed in your profile, you can evaluate pretty quick using Cargo-run. This may become how I write Rust going forward, if I can ...
Since rust-clippy normally works at compile time, it should get integrated into whatever you are using for compiling Rust code in Emacs (e.g. cargo-minor-mode). This is touched on in this blog post on setting up Emacs for Rust, in case you have not seen it already.
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 ...