Module case mismatch errors

69 views
Skip to first unread message

Bram Verburg

unread,
Jan 17, 2017, 5:08:32 AM1/17/17
to elixir-lang-core
Hi,

The error messages produced by Erlang/Elixir on a module name case mismatch when using a case-insensiteve FS can be confusing/intimidating:

iex(1)> Genserver.start_link(MyApp.Worker, [], name: MyApp.Worker)

09:57:03.286 [error] Loading of /lib/elixir/ebin/Elixir.Genserver.beam failed: :badfile

09:57:03.287 [error] beam/beam_load.c(1376): Error loading module 'Elixir.Genserver':
  module name in object code is Elixir.GenServer

** (UndefinedFunctionError) function Genserver.start_link/3 is undefined (module Genserver is not available)
    Genserver.start_link(MyApp.Worker, [], [name: MyApp.Worker])

The :code_server logs in particular can send even an experienced developer down a rabbit hole, looking for a problem with the BEAM file.

I made a PR to detect this particular issue, and improve the error message with a helpful suggestion ("Did you mean...?"):

Unfortunately the tests fail on Travis CI, presumably because it uses a case-sensitive FS. Which raises the question: should the suggestion be included in that case as well? My current implementation cannot support that. I see two options:

1. Keep the proposed implementation, because only case-insensitive FS users will see those confusing :code_server logs; the tests would have to be made conditional, to avoid failures on case-sensitive systems

2. Make the implementation more generic, to provide "Did you mean...?" suggestions for any module typos.

Any thoughts...?

Thanks,

Bram

Reply all
Reply to author
Forward
0 new messages