tldr; The current way that environments are handled encourages the development of monolithic apps. I’d like to start a discussion about this.
The dependencies of an “application/project” are compiled in the :prod environment, regardless of the environment in which the host code is being compiled. This applies to mix compile, mix hex.publish and so on—anything that looks at the project as a whole.
If the developer is working in just that one mix project, then this is fine: the dependencies are basically 3rd party libraries, and are used as-is.
But say the developer (eg me) wants to decouple a monolithic application into a number of components, one mix project per component. When I do this, I have configuration information that is environment specific: paths, debug levels, and even dependencies. But now I have a problem: a component tests OK when run in isolation, but when used as a dependency of another component via a path:, it fails, because it is no longer running in a development config.
For example, we might have the following dependencies in two components' mix.exs files.
component 1:
component2:
If we compile component 1, then component2 will be compiled in :prod mode, and it will look for component3 in hex, and not locally. This will either fail, or it will use an out-of-date version of component3 (assuming we're currently working on all three components).
You might say the answer is umbrellas, but I would disagree. I want to champion looser coupling than that (but that's a diversion away from the topic of this post)
I suspect the only common use of path dependencies is the one I describe: someone developing two or more components in parallel.
So, could mix be changed so that path dependencies are compiled in the same environment as the project that uses them? I can't see this causing any problems, as they are already treated very differently than the other dependency types. This would automatically fix any use of environment-sensitive values during development and testing.
I'd be happy to create a PR if this sounds like a good idea? I'd be sure to update the docs.
Cheers
Dave
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/b1d5c3a6-f3c5-4443-b5c6-a6f10aea6d55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
> You can use the option env: Mix.env() I'm your mix dependency tupple to partially solve this. You don't get iex recompiles either which would nice.Yes, passing env: Mix.env() is exactly what umbrellas do too. I think iex recompiles could be made to work for paths and umbrellas (since umbrellas are path deps) by calling "deps.compile" in IEx.Helpers.recompile().
\*Not sharing configuration is by design since configuration is a global storage. If we simply imported configuration from dependencies, it means any dependency could do "config :kernel, :some_vm_setting, :value", and that could drastically affect your application behaviour - and finding the root cause would be rather tricky.
1. Closing the repository you want to fix the bug2. Fixing the bug3. Verifying that the bug is fixed by depending on the local dependency using :path
1. start parent app2. call recompile()3. change path dep4. call recompile() and check it works5. change path dep6. call recompile() and check it worked again
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/3142851f-07d8-48bc-8a00-304feae470f1%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/3142851f-07d8-48bc-8a00-304feae470f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4Kyt0kq7%3DVC27UV1L5KjaCgaW-kD4%2Bq4qsMt3uAn5Kjzg%40mail.gmail.com.
To answer an earlier question, I think there is another case where someone would use a path dependency.Imagine that you are using dependency X and that dependency has a bug. You want to fix that bug, that usually means:1. Closing the repository you want to fix the bug2. Fixing the bug3. Verifying that the bug is fixed by depending on the local dependency using :path
I agree this is a possible case, but I’d argue that (a) it’s rare, and (b) its one of those cases where you’re already changing the dependency, so adding an env: is not a hardship.
But I’m not too fussed about this now that we can alias in_umbrella :)
Maybe we could find a better name for it that would work both inside and outside of umbrellas? We could call it "sibling: true" but I find too vague. Thoughts?
This flag is used to indicate that the dependency is used in the same environment as the dependor. So how about something like:
same_env: true
in_my_env: true
{:foo, in_umbrella: true}
{:foo, path: "../foo", env: Mix.env()}
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/13efe6fc-3a77-4ea4-8a48-4a91680802b3%40googlegroups.com.
On Monday, July 16, 2018 at 3:11:25 PM UTC-5, José Valim wrote:
Dave, just to make sure that something did not get lost in the way.:in_umbrella today means more than "same_env". The following:{:foo, in_umbrella: true}Means:{:foo, path: "../foo", env: Mix.env()}
OK, I didn’t think about that aspect.
How about is_peer:, meaning it is treated the same. And make it an alias, so in_umbrella still works.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/28457c75-64d3-4f2f-acd4-5fbdba5274ae%40googlegroups.com.