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

Strange compilation error: could not load module ExampleWeb.RoutexBackend due to reason :nofile #2

Closed
sfusato opened this issue May 3, 2023 · 4 comments

Comments

@sfusato
Copy link

sfusato commented May 3, 2023

  1. mix phx.new --no-ecto example
  2. added the dependecy: {:routex, "~> 0.1.0-alpha.2"}
  3. copied over example_web.ex and routex_backend.ex from routex_example app
  4. wrapped the get "/" in router.ex in preprocess_using ExampleWeb.RoutexBackend do block
preprocess_using ExampleWeb.RoutexBackend do
  get "/", PageController, :home
end

I get this compilation error:

Completed: ExampleWeb.RoutexBackend ⇒ Routex.Extension.Alternatives.configure/2
Completed: ExampleWeb.RoutexBackend ⇒ Routex.Extension.Translations.configure/2
Start: Processing routes with Routex.Processing
Completed: ExampleWeb.RoutexBackend ⇒ Routex.Extension.VerifiedRoutes.configure/2

14:08:44.878 [info] 
The default sigil used by Phoenix Verified Routes is overridden by Routex due to the configuration in `ExampleWeb.RoutexBackend`.

      ~p: localizes and verifies routes. (override)
      ~o: only verifies routes. (original)

Documentation: https://hexdocs.pm/routex/extensions/verified_routes.html


== Compilation error in file lib/example_web/router.ex ==
** (ArgumentError) could not load module ExampleWeb.RoutexBackend due to reason :nofile
    (elixir 1.14.0) lib/code.ex:1562: Code.ensure_loaded!/1
    (routex 0.1.0-alpha.2) lib/routex/processing.ex:136: Routex.Processing.transform_routes/3
    (routex 0.1.0-alpha.2) lib/routex/processing.ex:76: anonymous fn/3 in Routex.Processing.execute_callbacks/1
    (stdlib 4.0.1) maps.erl:411: :maps.fold_1/3
    (routex 0.1.0-alpha.2) lib/routex/processing.ex:75: Routex.Processing.execute_callbacks/1
    (stdlib 4.0.1) lists.erl:1350: :lists.foldl/3

I've checked the instructions from here to be sure I've not missed anything.

Couldn't reproduce the error in the routex_example app.

@sfusato sfusato changed the title Strange compilation error: could not load module DemoWeb.RoutexBackend due to reason :nofile Strange compilation error: could not load module ExampleWeb.RoutexBackend due to reason :nofile May 3, 2023
@BartOtten
Copy link
Owner

BartOtten commented May 3, 2023

Thanks for investing time to test this still early phase lib!

Have seen this during development and had my own little backdoor for troubleshooting. New version alpha3 made it public. Please let me know what you get with the debugging flag set.

https://hexdocs.pm/routex/troubleshooting.html

@sfusato
Copy link
Author

sfusato commented May 4, 2023

Here's the output:

Compiling 15 files (.ex)
Completed: ExampleWeb.RoutexBackend ⇒ Routex.Extension.Alternatives.configure/2
Completed: ExampleWeb.RoutexBackend ⇒ Routex.Extension.Translations.configure/2
Start: Processing routes with Routex.Processing
Executing: ExampleWeb.RoutexBackend ⇒ Routex.Extension.VerifiedRoutes.configure/2warning: 

!! Routex processing is wrapped in a task for debugging purposes. Compilation will fail !!


  (routex 0.1.0-alpha.3) lib/routex/processing.ex:51: Routex.Processing.__before_compile__/1
  (elixir 1.14.0) src/elixir_module.erl:399: anonymous fn/6 in :elixir_module.expand_callback/6
  (elixir 1.14.0) src/elixir_module.erl:398: :elixir_module.expand_callback/6
  (stdlib 4.0.1) lists.erl:1350: :lists.foldl/3
  (elixir 1.14.0) src/elixir_module.erl:382: :elixir_module.eval_form/6
  (elixir 1.14.0) src/elixir_module.erl:105: :elixir_module.compile/5

Completed: ExampleWeb.RoutexBackend ⇒ Routex.Extension.VerifiedRoutes.configure/2

12:05:59.554 [info] 
The default sigil used by Phoenix Verified Routes is overridden by Routex due to the configuration in `ExampleWeb.RoutexBackend`.

      ~p: localizes and verifies routes. (override)
      ~o: only verifies routes. (original)

Documentation: https://hexdocs.pm/routex/extensions/verified_routes.html


12:05:59.580 [error] Task #PID<0.310.0> started from #PID<0.287.0> terminating
** (ArgumentError) could not load module ExampleWeb.RoutexBackend due to reason :nofile
    (elixir 1.14.0) lib/code.ex:1562: Code.ensure_loaded!/1
    (routex 0.1.0-alpha.3) lib/routex/processing.ex:136: Routex.Processing.transform_routes/3
    (routex 0.1.0-alpha.3) lib/routex/processing.ex:76: anonymous fn/3 in Routex.Processing.execute_callbacks/1
    (stdlib 4.0.1) maps.erl:411: :maps.fold_1/3
    (routex 0.1.0-alpha.3) lib/routex/processing.ex:75: Routex.Processing.execute_callbacks/1
    (elixir 1.14.0) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
    (elixir 1.14.0) lib/task/supervised.ex:34: Task.Supervised.reply/4
    (stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Function: #Function<0.72679254/0 in Routex.Processing.__before_compile__/1>
    Args: []

== Compilation error in file lib/example_web/router.ex ==
** (exit) an exception was raised:
    ** (ArgumentError) could not load module ExampleWeb.RoutexBackend due to reason :nofile
        (elixir 1.14.0) lib/code.ex:1562: Code.ensure_loaded!/1
        (routex 0.1.0-alpha.3) lib/routex/processing.ex:136: Routex.Processing.transform_routes/3
        (routex 0.1.0-alpha.3) lib/routex/processing.ex:76: anonymous fn/3 in Routex.Processing.execute_callbacks/1
        (stdlib 4.0.1) maps.erl:411: :maps.fold_1/3
        (routex 0.1.0-alpha.3) lib/routex/processing.ex:75: Routex.Processing.execute_callbacks/1
        (elixir 1.14.0) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
        (elixir 1.14.0) lib/task/supervised.ex:34: Task.Supervised.reply/4
        (stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

Have seen this during development

In fact, if I remove the preprocess_using macro, compile and then later add it back it works.

@BartOtten
Copy link
Owner

BartOtten commented May 4, 2023

Seems a compile --force is not the same as a first compilation, neither is clearing the _build folder. The error raised on the first compilation lead me to the issue; so thanks for the reproduction steps on a clean Phoenix project.

== Compilation error in file lib/example_web/components/layouts.ex ==
** (RuntimeError) Elixir.Routex.Extension.VerifiedRoutes: Could not find a route definition matching ["images", "logo.svg"]

Fixed in 2e28451
Released a4!

@sfusato
Copy link
Author

sfusato commented May 5, 2023

Adding it to a clean project was the step before trying to add it to a larger project. Will report back if I bump into anything.

== Compilation error in file lib/example_web/components/layouts.ex ==
** (RuntimeError) Elixir.Routex.Extension.VerifiedRoutes: Could not find a route definition matching ["images", "logo.svg"]

I was also getting that, as well as one for ~p"/assets/app.css" when doing the compilation trick by adding preprocess_using as a subsequent change. All fixed with the last release.

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

No branches or pull requests

2 participants