lokoloko

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:

  1. mix phx.new islands_interface --no-ecto
  2. 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:

  1. 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.
  1. 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?

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

We're in Beta

About us Mission Statement