Mix will not recompile the app when change the "config.exs" in umbrella

➜  tree
├── README.md
├── _build
│   └── dev
│       ├── consolidated
│       │   ├── Elixir.Collectable.beam
│       │   ├── Elixir.Enumerable.beam
│       │   ├── Elixir.IEx.Info.beam
│       │   ├── Elixir.Inspect.beam
│       │   ├── Elixir.List.Chars.beam
│       │   └── Elixir.String.Chars.beam
│       └── lib
│           └── ks
│               └── ebin
│                   ├── Elixir.Ks.beam
│                   └── ks.app
├── apps
│   └── ks
│       ├── README.md
│       ├── config
│       │   └── config.exs
│       ├── lib
│       │   └── ks.ex
│       ├── mix.exs
│       └── test
│           ├── ks_test.exs
│           └── test_helper.exs
├── config
│   └── config.exs
└── mix.exs

12 directories, 17 files

This is a simple umbrella app

I had add import_config "../apps/*/config/config.exs" this code in “config/config.exs”

And my mix version is “1.5.2”

When I try to change the “apps/ks/config/config.exs” file, and run mix compile , it will not recompile the ks-app

I don’t know it’s a bug or something else

Any suggestion will be helpful


1 Like

exs is for script, only ex files get compiled…

It’s also the case for test files, which ends with exs. They are not compiled.

You will get more info here

1 Like

But, if try to touch “apps/ks/mix.exs”, mix will recompile the ks-app and generate new ks-app

1 Like

Touch like add new dependencies?

I tried to touch one of my mix file, I add a comment, it didn’t recompile.

Try touching one of your ex files, like in lib… and see if it recompiles.

1 Like

For touch, I just add some blank-lines in “apps/ks/mix.exs”, thenmix compile will work

DId you use the same version of mix with me?

1 Like

I am on elixir 1.5.2, and You?

BTW Adding even a single blank char in any ex files recompiles on my machine.

And exs files are not meant to be compiled, they are used in script mode.

From the doc

In addition to the Elixir file extension .ex, Elixir also supports .exs files for scripting. Elixir treats both files exactly the same way, the only difference is in intention. .ex files are meant to be compiled while .exs files are used for scripting. When executed, both extensions compile and load their modules into memory, although only .ex files write their bytecode to disk in the format of .beam files.

1 Like

Yes, we are same version

And just imagine one case, we will put something in “apps/ks/config/config.exs”, and we will get the config from this file, looks like @url Application.get_env(:ks, :url) in ks-app

When we try to change the config and recompile, the new config should be loaded to “.ex” file, it should work, right?

And I’m sure that change the “apps/ks/mix.exs” is useful, so it’s not something about diff between “.ex” and “.exs”, it is a problem about mix

➜  x mix compile
➜  x vim apps/ks/mix.exs 
➜  x mix compile
==> ks
Compiling 1 file (.ex)
Generated ks app
➜  x
1 Like

I tested on an umbrella, this is what I get

$ mix compile
$ vim mix.exs 
$ mix compile
$ vim apps/next/mix.exs 
$ mix compile
==> next
Compiling 5 files (.ex)
Generated next app
==> next_web
Compiling 1 file (.ex)

So it seems touching script files at the root does nothing, but touch a script in any apps will recompile… That also sounds quite logical.

1 Like
➜  x mix compile
➜  x vim apps/ks/config/config.exs 
➜  x mix compile
➜  x 
➜  x 

haha, but change config file does not work, so problem is still here

1 Like

You can use mix compile --force.

Mix should recompile the project if you change any file inside “config”.

My guess is that you may be invoking a custom task that does not ask your project to compile. It is the responsibility of every Mix task to say which state they expect the application to be: compiled, loaded, etc.

If it still fails, can you push a sample project that reproduces the issue to GitHub? I will gladly take a look at it.

According to https://github.com/elixir-lang/elixir/blob/master/lib/mix/lib/mix/tasks/compile.elixir.ex#L68-L70, I think Elixir only recompile if the files in the root config are modified. Modify config files in umbrella apps cannot recompile the project.

You are correct. We already have an open issue to revisit how loading of configs in umbrellas work, we will make sure to revisit this issue as well.

1 Like

I might hit the same issue (not recompile with config.exs change in umbrella project) with Elixir v1.9.1.

Is this “already exist open issue” tracked anywhere (e.g. github) ? Is it resolved ?