Update info for Erlang `crypto` module in Getting Started guide?

125 views
Skip to first unread message

Kenny Evitt

unread,
Sep 21, 2021, 11:33:52 AM9/21/21
to elixir-lang-core
On the Erlang libraries page of the current guide, for the `crypto` module:

> The `:crypto` module is not part of the Erlang standard library, but is included with the Erlang distribution. This means you must list `:crypto` in your project’s applications list whenever you use it. To do this, edit your `mix.exs` file to include:
>
> ```
> def application do
>   [extra_applications: [:crypto]]
> end
> ```

But in a reply on a recent Elixir Forum post, someone claimed:

> `:crypto` is a part of and is distributed with Erlang/OTP ...

And that doesn't seem to contradict what's in the Getting Started guide.

But I'm confused as to why that module should be added to the `:extra_applications` key. I just tried running the example code from the guide in a 'scratchpad' project that has NO (explicit) Mix deps, and only `:logger` listed in `:extra_applications` and the code worked fine in `iex`. Does that code work because I'm running it on my 'dev' computer? Would NOT adding `:crypto` to `:extra_applications` present a problem were I to deploy that project's code to another computer?

Or is `crypto` now (somehow) part of "the Erlang standard library"?

I'm just curious! But, if the guide is now incorrect about this, I'd be happy to submit a PR with any suitable changes.

José Valim

unread,
Sep 21, 2021, 11:39:25 AM9/21/21
to elixir-l...@googlegroups.com
The wording here is definitely confusing. Erlang is a collection of applications and crypto is one of them. You need to include all of Erlang applications, outside of "kernel" and "stdlib" apps, in extra_applications. I will clarify the guides. Thanks!


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/58f100bd-b79c-4893-8f1f-ec8aea26d81dn%40googlegroups.com.

Kenny Evitt

unread,
Sep 21, 2021, 12:02:08 PM9/21/21
to elixir-lang-core
Thanks!

Does the example code for that module in the guide work _without_ adding the module to `:extra_applications` because I'm running it on my 'dev' computer? In the test project I used, there are NO (explicit) Mix deps, so I don't _think_ `crypto` could be being pulled in via some other dependency.

José Valim

unread,
Sep 21, 2021, 12:13:06 PM9/21/21
to elixir-l...@googlegroups.com
You will get warnings in recent Elixir versions because the app is missing.

It may fail if you assemble a release and no other app depends on crypto.

Kenny Evitt

unread,
Sep 21, 2021, 5:19:35 PM9/21/21
to elixir-lang-core
Someone else pointed out on the forum post I made that the reason I might be confused is because `crypto` _is_ included in all of the specific Erlang/OTP packages/distributions I'm using – but that that wouldn't be guaranteed for any such possible Erlang/OTP package/distribution.

I _think_ my confusion has mostly been dissolved – I've just been 'lucky' in that `crypto` has been, by default, a part of the Erlang/OTP that I've been using.

Thanks for your help!

Reply all
Reply to author
Forward
0 new messages