Vim interfering with Phoenix recompile after saving

So I’m having some trouble. Recently my phoenix code stopped reloading, when I would make a change to backend code. So I’ve been having to flip back a forth killing the server and reloading after every change. I’m currently using Vim and Ale for linting, I read a github issue that said this was an issue a couple years ago, not sure if its still an issue but It does go away if I switch to emacs or atom or another editor so it makes me think its most likely the same issue.

I’d like to keep using vim since most of my muscle memory is there, anyone have any work arounds or solutions for this? Any help would be appreciated.


Deactivate compile on save or any plugin that does it to lint. Or if you are able to, change them to use different folders than the project folder to temporary save, compile and lint.

You could tell vim to use an :editor MIX_ENV which is equal to :dev but does end up in ./_build/editor/ instead.

Those are the workarounds that I’m aware of. You can use those workarounds for any editor-plugin that compiles on save.

Thanks, not sure how to do that for Ale. I did confirm it is Ale doing it. I just removed it and the issue cleared itself up. Once I find the settings or another solution I’ll post it here.

Thanks for pointing me in the right direction.

1 Like

When you start vim as in MIX_ENV=edit vim your-project, does it work?

Is credo linting working for you with Ale? for the last week it has stopped working, and it doesn’t show any credo issues anymore, and I was wondering if the same was happening to you… :thinking:

Nope credo isn’t working either. I think it’s related. Because Phoenix doesn’t seem to think the file has changed when I save from Vim. I can live with out credo but restarting phx.server every few minutes is super annoying.

@NobbZ yes it does. Why would setting MIX_ENV=edit fix the issue?

Because you then use a different MIX_ENV, which compiles to ,/_build/edit instead of ./_build/dev, therefore Phoenix.CodeReload can actually compile stuff and realize it changed for dev as well.

Makes sense. I know I can’t set that in my .zshrc since mix phx.server would pick it up and cause the same issue right? This depends on mix phx.server starting in MIX_ENV=dev and the editor starting it in MIX_ENV=edit right?

Yes, it depends on the editor and phoenix are running in different environments.

Perhaps an alias vim="MIX_ENV=edit vim" would suffice?

1 Like

Exactly what I was thinking. You sir are a champion. Thanks for the assistance.

But be warned, this will probably brake when you start a terminal in vim and run phoenix in that :wink:

I suppose that and issue for another day. Good to know it might break it.

1 Like

I use my editor with mix in test mode, which compiles, runs tests, runs credo, and I see all results, plus it does not interfere with my dev server.

1 Like

Thanks for the tip. Have you noticed any weirdness with this kind of setup?

I wish their was a better solution this seems kind of hacky especially since this seems like a solvable issue.

1 Like

Only if I try to run mix test from the terminal while the IDE is open. ^.^;

How exactly are you doing it?

My assumption is, that he starts his editor with MIX_ENV=test, similar to how I proposed MIX_ENV=edit in this thread.

How to actually do this depends on your operating system, your shell and the editor.


My Operating System in mac os and I am trying to use neovim…Need help to make recompile and neomake work together. Could you point my to any good blog post or article. I tried “” post. but unable to get things work

In my opinion, the easiest way is to throw away the auto-recompile-and-reload-stuff of phoenix and do a more strict TDD approach, after tests pass go into a design phase, restarting phoenix as necessary.

At the end of a day/feature do some manual testing/playing around.

Precisely this. I should probably make a shell function for it or something, but I just keep doing it manually for all of vim and emacs and atom. ^.^;