Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Elixir 1.11 compilation warning #399

Merged
merged 1 commit into from
Oct 21, 2020
Merged

Fix Elixir 1.11 compilation warning #399

merged 1 commit into from
Oct 21, 2020

Conversation

crbelaus
Copy link
Contributor

This PR fixes the compilation warning produced by Ex Machina under Elixir 1.11.

Closes #398

Copy link
Collaborator

@germsvel germsvel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this fix! 🎉

@germsvel germsvel merged commit e3cfc70 into beam-community:master Oct 21, 2020
germsvel pushed a commit that referenced this pull request Nov 4, 2020
## Motivation

I'm getting the following warning after upgrading to elixir 1.11. 
Related #398 #399.

```
warning: Ecto.Type.cast/2 defined in application :ecto is used by the current application but the current application does not directly depend on :ecto. To fix this, you must do one of:

  1. If :ecto is part of Erlang/Elixir, you must include it under :extra_applications inside "def application" in your mix.exs

  2. If :ecto is a dependency, make sure it is listed under "def deps" in your mix.exs

  3. In case you don't want to add a requirement to :ecto, you may optionally skip this warning by adding [xref: [exclude: Ecto.Type]] to your "def project" in mix.exs

  lib/ex_machina/ecto_strategy.ex:62: ExMachina.EctoStrategy.cast_value/3
```

## Proposed Solution

By default, the list of applications to start is automatically inferred 
from the dependencies. Mix and other tools use the application list 
in order to start the dependencies before starting the application itself. 
If we use the `applications:` then no inference is done. In this case 
`ecto` was not been included as a dependency of the library.

A quick solution for this is to use the `extra_applications`, in this way 
we let the compiler infer from the dependencies list the applications 
that it needs to start.

Links:

- https://elixir-lang.org/blog/2017/01/05/elixir-v1-4-0-released/#application-inference
- https://hexdocs.pm/mix/Mix.Tasks.Compile.App.html
- https://stackoverflow.com/questions/44727642/elixir-mix-file-applications-vs-extra-applications-when-to-use-which
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler warning when using an a project using Elixir 1.11
2 participants