Don't want to miss out on Elixir news? Subscribe to ElixirPulse!

Library authors hate this one weird trick!

When I was working on TimeTravel (a record/replay debugger for LiveView) the biggest pain was swapping LiveView versions.

If I was going to cut a release, I needed to make sure that I specified the hex.pm version of LiveView (instead of my local path dependency). I forgot to do this on more than one occasion which led to useless versions of the package being deployed.

I thought I was relegated to live with this pain forever until I discovered the secret.

What’s the Secret?

mix deps.compile is the secret.

If you are working with a dependency that’s acting up and want to see what’s going on it can be difficult. However, the process is as easy as:

  1. Edit the relevant file(s) deps/ with dbg, inspect, etc.
  2. Re-compile the lib: mix deps.compile that_lib
  3. Rejoice as you receive debug messages and logs from the dependency

When you are done just run: mix do deps.clean, deps.get to restore the original version

Credit where credit is due

I learned this little tip from Nathan Long on the Elixir slack. If you know him, tell him I owe him a beer!