jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.69k stars 141 forks source link

UndefinedFunctionError :pretty_print #392

Closed pthompson closed 4 years ago

pthompson commented 4 years ago

Environment

Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.10.2 (compiled with Erlang/OTP 22)

Current behavior

When I run mix dialyzer on my umbrella project, all of my error output looks like this:


Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Unknown error occurred: %UndefinedFunctionError{arity: 1, function: :pretty_print, message: nil, module: Erlex, reason: nil}

Legacy warning: :0: Unknown function 'Elixir.IEx':'started?'/0


Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Unknown error occurred: %UndefinedFunctionError{arity: 1, function: :pretty_print, message: nil, module: Erlex, reason: nil}

Legacy warning: :0: Unknown function 'Elixir.Mix':env/0


Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Unknown error occurred: %UndefinedFunctionError{arity: 1, function: :pretty_print, message: nil, module: Erlex, reason: nil}

Legacy warning: :0: Unknown function 'Elixir.Mix.Project':config/0


Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Unknown error occurred: %UndefinedFunctionError{arity: 1, function: :pretty_print, message: nil, module: Erlex, reason: nil}

Legacy warning: :0: Unknown type 'Elixir.MyProject.MyModule':t/0

. . .

Expected behavior

I would expect not to get the _Unknown error occurred: %UndefinedFunctionError{arity: 1, function: :prettyprint, message: nil, module: Erlex, reason: nil} errors.

asummers commented 4 years ago

This is strange to me. I'm wondering if you have something installed as a mix archive for Dialyxir but not Erlex? Can you run mix archive?

pthompson commented 4 years ago

This is what I get:

$ mix archive
* dialyxir-1.0.0 * hex-0.20.5 * phx_new-1.4.16 Archives installed at: /Users/patrick/.mix/archives

asummers commented 4 years ago

So the annoying thing about mix archives is that if they have dependencies (like Dialyxir does with Erlex) you need to install all dependencies as archives too. So in your case you need to install Erlex 0.2.6 as an archive, then your error should go away.

mix archive.install hex erlex

pthompson commented 4 years ago

That did the trick, thanks!

Should that be added to the README?

asummers commented 4 years ago

We removed the section on directions for installing as archives a while back, as it's not the recommended way to do so (for reasons you discovered, among others; see: https://github.com/jeremyjh/dialyxir/pull/276) so I don't think so, in this case.

pthompson commented 4 years ago

Got it, thanks for your help!