Elixir - How to solve recompile :noop Issue using VIM

Nov 15, 2018

Many of us are using more advanced editors such as Vim, Visual Studio Code, etc,. We all depend on the linters too much to correct our mistakes such as syntax errors. So, what is this specific topic related to? If you have started asking this question and you have found this link means, you are in the right place.

Let’s consider our normal dev course:

Elixir-Shell-Recompile-Noop-Issue-Dummy-App-Screenshot
Elixir-Shell-Recompile-Noop-Issue-Dummy-App-Screenshot

What’s happening?

Most of the elixir developers know why it is showing and unfortunately, there isn’t a proper tool to solve it except manually exporting or aliasing the environment variable. Most of us are good with them! But for the new comers, I’m going to elaborate as to why this is happening!

Environment Variable as Solution:

How to solve if you are using VIM:

Add the following line to your ~/.vimrc or vim config file:

au FileType elixir let $MIX_ENV = 'test'

This is an autocommand belonging to vimscript which checks for elixir filetype and exports an environment variable for linter to compile using test environment automatically if the opened filetype is elixir.

Now, if you make a change to your code and recompile on the shell, it will recompile without any problem! except human errors!

Why TEST environment specifically?

Because, the environment variable that you are exporting are by default are the compile time configs dev.exs, prod.exs and test.exs, any other variable that you specify will result in compile time error, making you elixir based extensions fail!

For example, if you export MIX_ENV=dummy, the your extensions will fail with an error, dummy.exs config file not found!.


   elixir (5) , erlang (8) , functional-programming (3) , vim (1)