Fl4m3Ph03n1x

Fl4m3Ph03n1x

Cannot launch Elixir Desktop app when MIX_ENV=test

Background

I have Phoenix umbrella application. When inside said application, I can run it without issues if MIX_ENV=prod. However, if I do mix test while MIX_ENV=dev, I get an error.

Problem

The error I have is as follows:

18:39:42.101 [error] ** wx object server {:local, WebInterface} terminating
** Last message in was {:"$gen_cast", {:show, &WebInterface.Endpoint.url/0}}
** When Server state == %Desktop.Window{
  module: nil,
  taskbar: nil,
  frame: {:wx_ref, 35, :wxFrame, []},
  notifications: %{},
  webview: {:wx_ref, 49, :wxWebView, []},
  home_url: &WebInterface.Endpoint.url/0,
  last_url: nil,
  title: "Market Manager",
  rebuild: 0,
  rebuild_timer: {:interval, #Reference<0.2679771817.2635857922.255366>}
}
** Reason for termination ==
** {:badarg,
 [
   {:erlang, :binary_to_existing_atom,
    ["Elixir.WebInterface.Endpoint.HTTP", :utf8],
    [error_info: %{module: :erl_erts_errors}]},
   {:elixir_aliases, :safe_concat, 1,
    [file: ~c"src/elixir_aliases.erl", line: 139]},
   {WebInterface.Endpoint, :url, 0,
    [file: ~c"lib/web_interface/endpoint.ex", line: 4]},
   {Desktop.Window, :prepare_url, 1,
    [file: ~c"lib/desktop/window.ex", line: 666]},
   {Desktop.Window, :handle_cast, 2,
    [file: ~c"lib/desktop/window.ex", line: 604]},
   {:wx_object, :handle_msg, 5, [file: ~c"wx_object.erl", line: 493]},
   {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 241]}
 ]}

Reading this, I understand the problem comes from my application.ex, namely:

@impl true
  def start(_type, _args) do
    children = [
      Telemetry,
      {Phoenix.PubSub, name: PubSub},
      Endpoint,
      Manager,
      %{
        id: Desktop.Window,
        start:
          {Desktop.Window, :start_link,
           [
             [
               app: :web_interface,
               id: WebInterface,
               title: "Market Manager",
               size: WindowUtils.calculate_window_size(0.6, 0.8),
               menubar: MenuBar,
               icon: "static/images/resized_logo_5_32x32.png",
               url: &WebInterface.Endpoint.url/0    # This line seems to be a problem
             ]
           ]},
        restart: :transient,
        shutdown: 5_000
      }
    ]

    opts = [strategy: :one_for_one, name: WebInterface.Supervisor]

    Supervisor.start_link(children, opts)
  end

After reading more on the subject I changed my config/test.exs to this:

import Config

config :web_interface, WebInterface.Endpoint,
  http: [ip: {127, 0, 0, 1}, port: 4002],
  secret_key_base: "some_key",
  server: true,
  check_origin: false

But this still does not fix the issue.

In contrast, this is my config/prod.exs:

config :web_interface, WebInterface.Endpoint,
  http: [ip: {127, 0, 0, 1}, port: 80],
  cache_static_manifest: "priv/static/cache_manifest.json",
  secret_key_base: "some_key",
  check_origin: false,
  server: true

But the issue still occurs.

Questions

  • Why am I having this issue?
  • How can I fix it?

Marked As Solved

Fl4m3Ph03n1x

Fl4m3Ph03n1x

Answer

Turns out that in a previous launch of the application, wxWidgets (the process) had exited in a bad state. Perhaps it crashed or something else happened, but what matters here is that trying to restart it was impossible.

I had to restart my machine to start everything in a new clean state.
I also deleted the _build folder to be sure.

This solved the issue.

Where Next?

Popular Frontend topics Top

New
brian
I’m working with a designer who created a design in Photoshop. I am mostly a Node.js and Android dev, but when I have worked with designe...
New
david-j-m
Hi, have a svelte spa gallery site - repl here. Have a couple of category buttons - Oil on Canvas and WaterColor… Sidebar contains all im...
New
sona11
What is the difference between tuple relational calculus (TRC) and domain relational calculus (DRC)? What distinguishes them from relatio...
New
sona11
I was working on a project that required me to update data in a SQL database. I initiated a transaction and modified the data with a seri...
New
Fl4m3Ph03n1x
Background I have a Phoenix application, where all pages (expect the login page) have a menu at the top. This menu will therefore only a...
New
Fl4m3Ph03n1x
Background I have a button that may be disabled or not, depending on a set of conditions. I want to disable/enable the button without hav...
New
Julien0577
Hi all, Anybody knows how to do this menu animation? (from BBVA APP, they have the same for both android and iOS app). Is it custom?...
New
wilsoc31
First time building an app. It will run for Android and also for iPhone 15 but will not for iPod. Not sure why or where to even begin. ...
New
Clintonsuck
Hello, I am new and trying to build my first app. So far, everything was going okay, but now I’m stuck and don’t know how to proceed. May...
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1031 17377 381
New
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File &gt; New Rule: And select Deny, O...
New
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New