Fl4m3Ph03n1x

Fl4m3Ph03n1x

Changing endpoint.ex to “use Desktop.Endpoint” breaks Desktop app

Background

I have created a fresh Phoenix app using mix phx.new.web web_interface --no-dashboard --no-ecto --no-gettext --no-mailer inside an Umbrella app.

After following the basic installation instructions for the dependencies and changing my application.ex to:

defmodule WebInterface.Application do
  use Application

  alias Desktop
  alias WebInterface.{Endpoint, Telemetry, PubSub}
  alias WebInterface.Live.MenuBar

  @impl true
  def start(_type, _args) do
    children = [
      Telemetry,
      {Phoenix.PubSub, name: PubSub},
      Endpoint,
      {Desktop.Window,
       [
         app: :web_interface,
         id: WebInterface,
         title: "Market Manager",
         size: {940, 980},
         menubar: MenuBar,
         icon: "static/images/resized_logo_5_32x32.png",
         url: &WebInterface.Endpoint.url/0
       ]}
    ]

    opts = [strategy: :one_for_one, name: WebInterface.Supervisor]
    Supervisor.start_link(children, opts)
  end

  # boilerplate code bellow
end

I was able to launch my Desktop application and have it working.

Problem

However, after changing endpoint.ex following the instruction #3 here:

I was no longer able to launch the application due to an error:

08:30:14.411 [notice] Application runtime_tools exited: :stopped
** (Mix) Could not start application web_interface: WebInterface.Application.start(:normal, []) returned an error: shutdown: failed to start child: WebInterface.Endpoint
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function Phoenix.Endpoint.Supervisor.url/1 is undefined or private
            (phoenix 1.7.2) Phoenix.Endpoint.Supervisor.url(WebInterface.Endpoint)
            (phoenix 1.7.2) lib/phoenix/config.ex:65: Phoenix.Config.cache/3
            (web_interface 2.2.0) lib/web_interface/endpoint.ex:2: WebInterface.Endpoint.url/0
            (phoenix 1.7.2) lib/phoenix/endpoint/supervisor.ex:425: Phoenix.Endpoint.Supervisor.log_access_url/2
            (phoenix 1.7.2) lib/phoenix/endpoint/supervisor.ex:17: Phoenix.Endpoint.Supervisor.start_link/3
            (stdlib 4.1.1) supervisor.erl:414: :supervisor.do_start_child_i/3
            (stdlib 4.1.1) supervisor.erl:400: :supervisor.do_start_child/2
            (stdlib 4.1.1) supervisor.erl:384: anonymous fn/3 in :supervisor.start_children/2

To me, this indicates that changing Phoenix.Endpoint to Desktop.Endpoint is no longer necessary.

Question

  1. Is the documentation outdated?
  2. If not, am I missing something? Given that before the change the application worked, what could be causing the issue (assuming the change is indeed necessary)?

It is worth noting however, that the creation of Phoenix projects inside Umbrella applications is currently bugged (see: Phoenix 1.7 welcome page assets not showing properly - Questions / Help - Elixir Programming Language Forum) but I don’t think this is related.

Marked As Solved

Fl4m3Ph03n1x

Fl4m3Ph03n1x

So, after delving into the source code, I am of the opinion the documentation (desktop/guides/your_first_app.md at main · elixir-desktop/desktop · GitHub) needs to be updated, specifically:

def deps do
[
    {:desktop, "~> 1.4"}
]
end

Needs to be:

def deps do
[
    {:desktop, "~> 1.5"}
]
end

As v1.4 breaks with Phoenix LiveView 1.18. More info:

Where Next?

Popular Frontend topics Top

New
Zuber
How to make a website like webnovel and wattpadd where subscribers and logged in user post stories like their own Novel in a website and ...
New
The_Exile
I am new to programming. I started reading Eloquent Javascript 3rd Edition, as the book comes highly recommended as a good place for beg...
/js
New
pillaiindu
I mean, when you render all the HTML at the server side and the data is sent through HTTP requests, except only if some tiny things are d...
New
beberardinelli
Hi! I just started coding a few months ago and I am trying to get all the help I can get. My friend showed me this debugging tool called...
New
sona11
I have a 1D array of numbers and need help splitting them into groups using a jagged array so that I can perform a series of computations...
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
JessicaW33
Hello everyone, I’m working on optimizing the performance of React Native applications and would like to gather insights and suggestions...
New
sona11
I’m currently working on a JavaScript project that involves converting user-supplied text to numbers. Dealing with different areas and th...
/js
New
hosseinkhosromanesh
hello , i should code a cluster like image bellow we have no challenge in coding backend but in front need some clue to do this its a dy...
/js
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
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
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New