Observer in iex -S mix error: (UndefinedFunctionError) function :wx_object.start/3 is undefined

Is there a known issue with :observer with Elixir 1.15 that I’m unaware of? I’ve added :observer to :extra_applications but it gives this error:

iex(1)> :observer.start
** (UndefinedFunctionError) function :wx_object.start/3 is undefined (module :wx_object is not available)
    :wx_object.start(:observer_wx, [], [])
    (observer 2.15.1) observer_wx.erl:70: :observer_wx.start/0
    iex:1: (file)

If I start just iex (as opposed to iex -S mix), it works just fine. Is there something else I must add to the mix config?

1 Like

:observer is a module in the :runtime_tools application. You’d need to add the latter.

works for me

extra_applications: [:logger, :wx, :observer, :runtime_tools]
6 Likes

Thanks! I had :runtime_tools but missed :wx, it works!

If you don’t want to modify your application you could also run this in IEx:

Mix.ensure_application!(:wx)
Mix.ensure_application!(:runtime_tools)
Mix.ensure_application!(:observer)
:observer.start()
18 Likes

I can confirm that, from Erlang/OTP 27, only:

Mix.ensure_application!(:observer)
:observer.start()

is required.

18 Likes

This does seem to work, but it’s still necessary to include both :wx and :observer in :extra_applications. Is this intended?

I did some tests locally and that did not seem to be required, only Mix.ensure_application!(:observer); :observer.start() from Erlang/OTP 27.

Sorry, I wasn’t very clear. What I mean is that the following works:

$ mix new foo && cd foo
$ iex -S mix
iex> Mix.ensure_application!(:observer); :observer.start()

But this doesn’t:

$ mix new foo && cd foo
$ vim mix.exs # or whatever
# add :observer to :extra_applications list in application/0
$ iex -S mix
iex> :observer.start()

I thought both should work, and the docs for Mix.ensure_application!/1 sort of imply they’re typically functionally equivalent.

1 Like

You need to add :wx to extra applications because it is an optional dependency of :observer. The ensure_application! also considers optional dependencies.

2 Likes

Hi there! :wave:

I might misunderstood what you said there, but despite running Erlang/OTP 27 and Elixir 1.17 it still seems that :observer is not enough:

iex -S mix
iex(1)> Mix.ensure_application!(:observer)
:ok
iex(2)> :observer.start()
** (UndefinedFunctionError) function :wx_object.start/3 is undefined (module :wx_object is not available)
    :wx_object.start(:observer_wx, [], [])
    (observer 2.16) observer_wx.erl:71: :observer_wx.start/0
    iex:2: (file)

From what I understand from this:

Is that Mix.ensure_application!(:observer) should be failing due to :wx not being there. Is that correct?

1 Like

Can you share the output of elixir --version? Even if you have OTP 27 installed, your Elixir version could’ve been compiled with an earlier OTP.

EDIT: Actually, that doesn’t seem to matter. Even with Elixir 1.17.0-otp-25, I’m still seeing the following:

$ mix new ppicom && cd ppicom
$ elixir --version
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.17.0 (compiled with Erlang/OTP 25)
$ iex -S mix
Erlang/OTP 27 [erts-15.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Interactive Elixir (1.17.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Mix.ensure_application!(:observer)
:ok
iex(2)> :observer.start()
:ok
1 Like

Now I just remembered, for the installation of Erlang to work on Apple Silicon when using ASDF I have to use the --without-wx flag. That might be the culprit.

1 Like

In case it can affect someone else, I had to reinstall Erlang with wx following the steps from this Gihub issue (Unable to install Erlang/OTP 27.1 and 26.2.5.3 on Apple Silicon macOS and Xcode 16.0 · Issue #319 · asdf-vm/asdf-erlang · GitHub), and now I can:

iex -S mix
> Mix.ensure_application! :observer
> :observer.start
2 Likes