There. Our ‘hotfix’ directory should now have both the source
and the compiled BEAM equivalent.

So far, our system is still unaware of the new version of ‘foo.’
To change that, first we must tell our system about this special
code path, and then finally load the new ‘foo’ into our system.
We do that as follows:

3> code:add_patha("/home/jimbo/hotfix").
4> code:load_file(foo).

You will notice that we went with the ‘add_patha’ routine
rather than ‘add_pathz.’ In essence, we want our ‘hotfix’
directory to take precedence wherever ‘foo’ is found.

Presto change-o

Believe it or not, our production system has now been patched with
the hotfix! The typo is history — which means the phones should
have stopped ringing. And it only took a couple lines Unix & a
mere few lines in the Erlang-shell. How great is that?

Before we ping the boss about the good news, it’s good housekeeping
to double-check our efforts, and, in one last step, to purge the old
version of ‘foo’ from the runtime system. You can do that as follows:

5> foo:module_info(). % compare to previous
6> code:soft_purge(foo).

And with that, you can safely detach from the Erlang shell
and get back to hacking the fun tricky stuff.

You can see that in a pinch, even complicated things like
changing the code of a live system is a snap in OTP
land…Isn’t it amazing how much power you can wield with
just the knowhow and a few keystrokes when you have Erlang
by your side?