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.

2 536 1

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:

Popular Frontend topics Top

PragmaticBookshelf
Design websites faster than ever using Sass—the most mature and popular CSS meta-language. Code the right way in Sass with short, clear e...
2 945 0
New
AstonJ
I was watching this video by Richard Feldman (Elm core team) and he’s predicting TypeScript is going to take over the JS world: ...
12 1389 3
New
CommunityNews
Microsoft’s Introduction to JavaScript video series will equip users with the basic skills to start building apps with the popular progra...
3 1126 1
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
0 1911 0
New
AstonJ
Just discovered AssemblyScript (our portal is here). It…“aims to make it easy to compile to WebAssembly using TypeScript, no strings att...
1 1260 1
New
First poster: bot
Fable 3.0.2 has been released. Link: Release 3.0.2 · fable-compiler/Fable · GitHub
0 950 0
New
First poster: bot
Fable 3.1.2 has been released. Link: Release 3.1.2 · fable-compiler/Fable · GitHub
0 1095 0
New
First poster: bot
Flame is a fast & simple framework inspired by the Elm architecture for building web applications in PureScript
0 1282 0
New
First poster: bot
A new Angular blog post/announcement has been posted! Get the full details here: https://blog.angular.io/build-more-accessible-angular-...
0 1014 0
New
First poster: bot
Pablo is a small, open-source JavaScript library for SVG, the web standard for vector graphics. It can be used for vector-based art, game...
0 1014 0
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
193 4239 93
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...
236 5547 90
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
44 5004 35
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
64 2918 29
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
78 3397 24
New
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
36 3222 18
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
0 2435 0
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
41 2556 20
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
1 1288 1
New