Closed justinbkay closed 5 years ago
Seems as though I needed to add {:plug_cowboy, "~> 1.0"} to my mix.exs file for this to work.
I already had {:plug_cowboy, "~> 2.5"}
in my mix.exs deps, and I was getting the warning:
warning: Plug.Swoosh.MailboxPreview.init/1 is undefined (module Plug.Swoosh.MailboxPreview is not available or is yet to be defined)
│
41 │ forward "/mailbox", Plug.Swoosh.MailboxPreview
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ lib/auction_web/router.ex:41
I searched for Plug.Swoosh.MailboxPreview
and the first hit was:
HexDocs
Plug.Swoosh.MailboxPreview — Swoosh v1.14.2
So, I looked at the Swoosh docs, and Swoosh contains the module Plug.Swoosh.MailboxPreview
, so I added Swoosh as a dependency in mix.exs:
defp deps do
[
{:phoenix, "~> 1.7.10"},
{:phoenix_html, "~> 3.3"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.20.1"},
{:floki, ">= 0.30.0", only: :test},
{:phoenix_live_dashboard, "~> 0.8.2"},
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
{:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:gettext, "~> 0.20"},
{:jason, "~> 1.2"},
{:plug_cowboy, "~> 2.5"},
{:auction, in_umbrella: true},
{:swoosh, "~> 1.14.3"},
{:hackney, "~> 1.20.1"}
]
end
Then I did mix.deps get
, then I started up my server: mix phx.server
. Yeah, the warning:
warning: Plug.Swoosh.MailboxPreview.init/1 is undefined (module Plug.Swoosh.MailboxPreview is not available or is yet to be defined)
│
41 │ forward "/mailbox", Plug.Swoosh.MailboxPreview
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ lib/auction_web/router.ex:41
was gone...but it was replaced by this:
00:29:05.113 [notice] Application runtime_tools exited: :stopped
** (Mix) Could not start application swoosh: exited in: Swoosh.Application.start(:normal, [])
** (EXIT) an exception was raised:
** (RuntimeError) missing hackney dependency
(swoosh 1.14.3) lib/swoosh/api_client/hackney.ex:26: Swoosh.ApiClient.Hackney.init/0
(swoosh 1.14.3) lib/swoosh/api_client.ex:43: Swoosh.ApiClient.init/0
(swoosh 1.14.3) lib/swoosh/application.ex:7: Swoosh.Application.start/2
(kernel 9.1) application_master.erl:293: :application_master.start_it_old/4
What the heck, mix deps.get
??! I checked the Swoosh docs, and sure enough you have to add hackney
as a dependency. I was left with this:
defp deps do
[
{:phoenix, "~> 1.7.10"},
{:phoenix_html, "~> 3.3"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.20.1"},
{:floki, ">= 0.30.0", only: :test},
{:phoenix_live_dashboard, "~> 0.8.2"},
{:esbuild, "~> 0.8", runtime: Mix.env() == :dev},
{:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:gettext, "~> 0.20"},
{:jason, "~> 1.2"},
{:plug_cowboy, "~> 2.5"},
{:auction, in_umbrella: true},
{:swoosh, "~> 1.14.3"},
{:hackney, "~> 1.20.1"}
]
end
After mix deps.get
and mix phx.server
: Ta da! No more warnings or errors. Good luck.
When I try to compile after updating the package to 0.23.3 from 0.8.1, I get an error saying that the Plug.Swoosh.MailboxPreview module is not available. As far as I can tell everything is set up in the application correctly. The error comes from the router.ex file:
== Compilation error in file lib/refleq_web/router.ex == ** (UndefinedFunctionError) function Plug.Swoosh.MailboxPreview.init/1 is undefined (module Plug.Swoosh.MailboxPreview is not available) Plug.Swoosh.MailboxPreview.init([base_path: "/dev/mailbox"])
Router: