:extra_applications :ssl isn't started when my library is running

I generated a dummy library that calls an HTTPS url using Erlang’s httpc module.

Here’s what it’s doing:

case System.get_env("APP_NAME") do
      nil ->
          "Environment variable for APP_NAME must be set before calling any features."

      app_name ->
        token_endpoint =

        {:ok, {{scheme, 200, status_text}, _headers, body}} =
          :httpc.request(:get, {token_endpoint, []}, [], []) |> IO.inspect()

In my mix.exs file:

# Run "mix help compile.app" to learn about applications.
def application do
    extra_applications: [:logger, :inets, :ssl]

According to the docs:

The most commonly used keys are:

• :extra_applications - a list of OTP applications your application
depends on which are not included in :deps (usually defined in deps/0 in
your mix.exs). For example, here you can declare a dependency on
applications that ship with Erlang/OTP or Elixir, like :crypto or :logger,
but anything in the code path works. Mix guarantees that these applications
and the rest of your runtime dependencies are started before your
application starts.

# sergiotapia at Sergios-iMac in ~/Work/test [23:49:07]
→ iex -S mix
Erlang/OTP 21 [erts-10.1.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Generated test app
Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :inets.start() # Excellent, this is already started seems like, right?
{:error, {:already_started, :inets}}
iex(2)> :ssl.start() # This wasn't running???
iex(3)> test.myfunction()
{:error, {:bad_scheme, "https"}}
** (MatchError) no match of right hand side value: {:error, {:bad_scheme, "https"}}
    (test) lib/test.ex:18: myfunction/0

Appreciate the help!


Found some really random comment from Jose on an unrelated stackoverflow comment and that led me to try using single-quotes

token_endpoint = 'https://foobar.com/api?app_id=#{app_name}'

That seems to have fixed the issue.


:httpc is an Erlang module. Most Erlang functions take Erlang strings as parameters which, in Elixir, are known as charlists. Charlists are represented with single quotes ' in Elixir. Hence why changing to single quotes worked here.