-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Module dependency not detected a compile time #10037
Comments
I wonder if it's because |
I just updated the notes to reflect it works fine in |
Kip, how are you checking if the module exists? It seems you are checking
it in a way that does not guarantee it was compiled, especially within Plug
that works at compile time. It feels your CLDR plug should call
Code.ensure_compiled on the module during its init.
Alternatively, you can change your loaded check to actually invoke a
function on the module: backend.__cldr__, and that will guarantee it is
loaded at runtime or guarantee it is compiled at compile time.
|
José, you are right, I'm only calling FWIW here's the current code: defp validate_app_and_scope!(app, module) when not is_nil(app) and is_atom(module) do
cond do
app in @app_options && Code.ensure_loaded?(module) ->
:ok
app in @app_options ->
raise ArgumentError, "Backend module #{inspect(module)} is unavailable"
true ->
raise ArgumentError, "App #{inspect(app)} is unknown"
end
end |
You do want to avoid it but given you are trying to verify it at compile-time, then at least on this case you shouldn't. Closing this for now but feel free to follow up if you have questions. |
I'm not certain if this is a bug or working as expected. If the latter then my apologies for the report.
Environment
Current behavior
A module referenced in a Plug configuration is not compiled at compile time in
:test
. In this test repo, the following error occursCode example
Reproduce the error
The error does not occur in
:dev
mode, presumably becausePlug.init/1
is called at runtime where as in:prod
and:test
its called at compile time.Workaround
require
ing the module forces compilation order.Expected behavior
The compiler detects the module dependency and compiles it.
The text was updated successfully, but these errors were encountered: