Cannot start observer: (UndefinedFunctionError) function :observer.start/0 is undefined

Amazing, thank you!

Since 1.15, Elixir prunes unused code paths. Adding the following line to project/1 callback of your mix.exs would do.

    prune_code_paths: Mix.env() == :prod,

This hack also works for some other erlang stuff, like common_test I needed in Enfiladex.

1 Like

TIL about the Elixir code pruning, thank you!

1 Like

This works, but also means you’re now only pruning paths in production, so all issues related to it only surface in production.

2 Likes

I use 4 environments, the commons and :ci for GHA/CI, in which I don’t prune codepaths (and mimic :prod in general.)

What can be the potential issues? Sorry, I’m not very knowledgeable about this, can you please elaborate a bit?

1 Like

Afaik mostly missing out on the speedups code path pruning are meant to bring. But I’ve seens code path pruning affect how you interact with applications you don’t explicitly depend on (in dev), like: Observer in iex -S mix - #5 by axelson

1 Like

I’m reading this too because I couldn’t start observer… :sweat_smile: Speed reasons, understandable.

2 Likes

I ran with the same issue with my Mac. Reinstalling Xcode developer tools solved it for me

Since I don’t see it only this thread, copying the solution referenced to above. Running

apt install -y erlang-observer

solves this error

iex(76)> :observer.start
** (UndefinedFunctionError) function :observer.start/0 is undefined (module :observer is not available)
:observer.start()

on Ubuntu.