The best way to find out which Hex package you need!

Notes

When I’m adding a package to my project, I always find it a pain to go to GitHub or Hexdocs to find the right version.

Recently, I came across a better solution!

Finding a version of a Hex package

Try mix hex.info <package>.

Let’s take a look at an example. My current project doesn’t have Oban, so I want to see which version I should target in my mix.exs file:

$ mix hex.info oban
Robust job processing, backed by modern PostgreSQL, SQLite3, and MySQL.

Config: {:oban, "~> 2.19"}
Releases: 2.19.2, 2.19.1, 2.19.0, 2.18.3, 2.18.2, 2.18.1, 2.18.0, 2.17.12, ...

Licenses: Apache-2.0
Links:
  Changelog: https://github.com/oban-bg/oban/blob/main/CHANGELOG.md
  GitHub: https://github.com/oban-bg/oban
  Website: https://oban.pro

There you go.

We can just add {:oban, "~> 2.19"} to our list of dependencies, and we’ll get version 2.19.2.

Checking what’s in your lock file

Don’t leave just yet. mix hex.info has another cool trick!

If you’re already using a package, you can use mix hex.info to see what’s in your lock file.

Let’s check which version of phoenix_test I have in my mix.lock file:

$ mix hex.info phoenix_test
Write pipeable, fast, and easy-to-read feature tests for your Phoenix apps in
a unified way -- regardless of whether you're testing LiveView pages or static
pages.

Config: {:phoenix_test, "~> 0.5.2"}
Locked version: 0.5.2
Releases: 0.5.2, 0.5.1, 0.5.0, 0.4.2, 0.4.1, 0.4.0, 0.3.2, 0.3.1, ...

Licenses: MIT
Links:
  Github: https://github.com/germsvel/phoenix_test

As you can see, I have a Locked version: 0.5.2.

No more diving through your lock file to figure out which version you actually have.

Want the latest Elixir Streams in your inbox?

    No spam. Unsubscribe any time.