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.

Popular Frontend topics Top

AstonJ
Inspired by @dbernheisel’s post here, which CSS framework do you use and why?
New
First poster: bot
React is Dead. Long live Reactive Rails! Long live StimulusReflex and ViewComponent!. Let me tell you about the feeling that I get when ...
New
First poster: bot
Fable 3.0.0-nagareyama-alpha-010 has been released. Link: Release 3.0.0-nagareyama-alpha-010 · fable-compiler/Fable · GitHub
New
First poster: bot
Why do ARM chips have an instruction with Javascript in the name (FJCVTZS)?. FJCVTZS is “Floating-point Javascript Convert to Signed fix...
New
First poster: bot
SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. ...
New
First poster: bot
passiomatic/elm-designer. A code generator for Elm UI. Contribute to passiomatic/elm-designer development by creating an account on GitH...
New
PragmaticBookshelf
Tailwind CSS is an exciting new CSS framework that allows you to design your site by composing simple utility classes to create complex e...
New
First poster: bot
ThinScript ThinScript is an experimental programming language that compiles to JavaScript, WebAssembly, and C. It’s meant to be a thin la...
New
ClaudiaGiv
I have a sveltekit project that is using GoTrue library for authentication. In development mode (npm run dev) everything works but when I...
New
magarrent
Welcome to @actionforms_io :rocket: No code - No backend Form sender for developers Send your without a backend Join now: https://www...
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
PragmaticBookshelf
A Hero’s Journey with Chris Pine @chrispine Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
New
OvermindDL1
Woooooooo! This is such a huge release for it, and 2 years incoming! In short, the library is now using an updated hyper backend (not j...
New
AstonJ
Chris Seaton, the creator of TruffleRuby has died. It appears from suicide :cry: He left this note on Twitter on the weekend: And one...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New