Emacs + alchemist - run iex -S mix phoenix.server?

Hey, I’m pretty new to emacs (have only used it a bit while reading Clojure for the brave and true). I installed the alchemist package, now by what I understand I should be able to run a repl from inside emacs itself without having to open a terminal window right? and probably start it with iex -S mix phoenix.server ?

Whenever I do M-x alchemist-iex-project-run I get /usr/local/Cellar/elixir/1.5.0/bin/elixir: line 127: exec: erl: not found

Process Alchemist-IEx exited abnormally with code 127

Does anyone know a good resource on how to setup emacs for this? Or should I just fire a terminal and do it normally while editing in emacs? Thanks

Hmmm, are you using a versioning environment like kerl or kiex?

Not really, should I set that up?

No need to. They can cause problems with the path though - which is why I asked :slight_smile:

I found this Stack Overflow answer from someone with the same problem: Elixir on Emacs: exec erl not found.

Another way to get a shell in emacs is to use M-x ansi-term RET RET, but it will probably have the same problem :stuck_out_tongue:

How do you start emacs? From a terminal or from your window manager?

If the latter, does the path it knows point to erl location?

Also if you used the latter, does the problem also exist when you start wands from a terminal that can “see” erl?

1 Like

Thanks I will check that out! When I open the emacs gui from the terminal it doesn’t show the previous error but shows another one from compilation.

Ah I was starting it from the window manager ( and I guess it doesn’t because I haven’t told it ) . Indeed when I open the emacs gui from the terminal it does !!! huuuu how do I tell him what’s the erl location? Or what is the best way to spin emacs? Right now I added it to the mac login, so it’s started by default but this points to the “app” without context - how do you start your emacs session? Thanks!

I don’t know how to do it in macOS… On linux I’d alter the contents of ~/.profile to contain something like this:

export PATH=/path/to/erlang/bin:$PATH

Changes to that file do require me to loout and back in again.

Yeah I use ~/.bash_profile for setting up a lot env stuff the problem is when I load emacs by going to the app it doesn’t care about the profile - when I run it from the terminal it loads the sessions profile and all is good and works. I would just like to have the app open on login (since it runs the emacs.app without context) with the ~/.bash_profile instead of opening a terminal and then executing emacs from it, since alchemist fires up the repl. I will dig a bit more on how to setup the env. Thanks

This is for bash only. .zprofile were for zsh.

~/.profile should be for the user, but as I said, I’m not sure if macOS does it that way as well.

Hi there, I’ve just set up emacs gui on macos. I am very used to zsh and faced the same issue of not being able to load the correct SHELL env when starting emacs.app from outside a terminal. Since I use a couple of extra env variables and extend $PATH quite a bit in my .zshrc, this was not really acceptable :wink:

I am using exec-path-from-shell and have configured it like so in my ~/.emacs:

;; ...
(when (memq window-system '(mac ns x))
;; ...

You will need to export $PATH from ~/.bash_profile or ~/.zshenv (it did not work from ~/.zshrc, but that’s stated in the docs):

export PATH=/usr/local/bin:/usr/bin:/bin # should be enough for most usages
export PATH=/usr/local/bin:$PATH # if you ignore what's in the docs ;)

Finally, no trouble finding erl or any other libraries and programs from emacs gui. I hope you already found a solution or that that helps


Thanks for the tip. I ended up not using alchemist server nor an emacs shell to run the server during dev, I just basically run it on a terminal tab - I can’t remember exactly how I got it working, but in the end it would lag a bit too much and nowadays I don’t see any inconvenience in running it outside of emacs

I agree, there are quite a few things I prefer doing in the terminal, like running a server or other heavy ongoing processes that would clutter the dev env, and don’t bother doing in emacs. But being able to seamlessly throw your buffer in a fresh iex session is still quite handy :slight_smile:
An extra keybinding for toggling between emacs and terminal makes it no pain at all