lokoloko
Question about adding a dependency in a phoenix project
I’m reading the amazing book Functional Web Development with Elixir, OTP, and Phoenix.
I encounter an issue when reading the section Adding a New Dependency in chapter 6 Generate a New Web Interface with Phoenix.
The section adds a project islands_engine to a new phoenix project islands_interface.
Here are the steps:
mix phx.new islands_interface --no-ecto- add a dependency in mix.exs:
defp deps do
[
...
{:islands_engine, path: "../islands_engine"}
]
end
By running iex -S mix phx.server, it will display {:islands_engine, 'islands_engine', '0.1.0'} after executing :application.which_applications() in the iex.
However, I don’t see the islands_engine in my output.
I’m using Elixir v1.7.2 and Erlang v21, while the book uses Elixir v1.4. Not sure whether it affects my output.
I tried two ways:
- add included_applications in
mix.exs:
def application do
[
...
included_applications: [:island_engine]
]
end
It doesn’t launch islands_engine.I read Erlang’s doc and find that:
The application controller automatically loads any included applications when loading a primary application, but does not start them. Instead, the top supervisor of the included application must be started by a supervisor in the including application.
- start the islands_engine supervisor tree in islands_interface’s
application.ex:
def start(_type, _args) do
...
children = [
supervisor(IslandsInterfaceWeb.Endpoint, []),
%{id: IslandsEngine.Application, start: {IslandsEngine.Application, :start, [nil, nil]}}
]
...
end
The approach can launch islands_engine, but it’s not what I want. The islands_engine supervisor tree would be a child of islands_interface supervisor tree. :application.which_applications still doesn’t output island_engine.
Do I miss anything? What’s the correct way to add a dependency in a phoenix project?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









