VegaLite.Viewer not working

The module worked ok before the Elixir was updated to 1.15.4, but now got error:

(RuntimeError) VegaLite.Viewer requires Erlang compilation to include the :wx module, but it’s not available
(vega_lite 0.1.7) lib/vega_lite/wx_viewer.ex:7: VegaLite.WxViewer.start/1
(vega_lite 0.1.7) lib/vega_lite/viewer.ex:17:

I checked both Code.ensure_loaded?(:wx) and Code.ensure_loaded?(:wxWebView) return true
Any idea?

Did you install Erlang through asdf or rtx and not through your OS’ package manager?

Erlang was Installed through brew in MacOS, not asdf.
It worked yesterday. I uninstalled and reinstalled Erlang, elixir, wx, all latest versions, but do not help.

What OTP version are you using (mix You might be able to just add :wx to your extra applications in your mix.exs file. extra_applications: [:logger, :wx]

Thank you. I tried that and in mix environments triggered Erlang gui, but VegaLite.Viewer is still not working, the same error message.

Okay I dug into this and I could recreate the same error as you (using Elixir 1.15.4), I’d try updating your OTP version to either 26.0.2 or 26.0.1, and it should work. If upgrading is not an option you can add prune_code_paths: false to mix.exs and it should also work.

works with extra_applications: [:wx]

  • erlang 26.0.2
  • erlang 26.0.1

works with prune_code_paths: false

  • erlang 26.0
  • erlang
  • erlang

Details: Changelog for Elixir v1.15 — Elixir v1.15.4

1 Like

Thank you again for you help. My OTP is 26.0.2, works, but VL is not working. Must be some configuration problems. I will create a new mix project and try again.

Sorry to have misled you, I believe I have made an error when switching between versions. If you change your mix.exs (for example by changing prune_code_paths between true/false), dependencies are not recompiled when you mix deps.compile (unless you use --force). So, I was just running my compiled dependencies with unpruned code paths on those versions making it seem like it worked on those versions.

I’m not too sure exactly how the code path pruning works, but I think unless VegaLite adds :wx to their :extra_applications VegaLite.WxViewer will never compile with the correct clauses in 1.15+ (because the Code.ensure_loaded check is done at compile time). Quick solutions that I can see are to use prune_code_paths: false, or try and PR extra_applications: [{:wx, :optional}] to VegaLite (if that’s the correct solution to the problem).

1 Like

Worked! Even disabled prune_code_path: false.

1 Like