# Programming Elixir 1.6 - Distillery-The Elixir Release Manager chapter commands for Elixir 1.9/Distillery 2.1

**URL:** <https://forum.devtalk.com/t/programming-elixir-1-6-distillery-the-elixir-release-manager-chapter-commands-for-elixir-1-9-distillery-2-1/1196>\
**Category:** PragProg Customers\
**Tags:** book-programming-elixir-1-6\
**Created:** [31 July 2020 14:25 UTC](https://forum.devtalk.com/t/programming-elixir-1-6-distillery-the-elixir-release-manager-chapter-commands-for-elixir-1-9-distillery-2-1/1196 "2020-07-31T14:25:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![veimis](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/v/b38774/32.png) [@veimis](https://forum.devtalk.com/u/veimis)\
**Post date:** [31 July 2020 14:25 UTC](https://forum.devtalk.com/t/programming-elixir-1-6-distillery-the-elixir-release-manager-chapter-commands-for-elixir-1-9-distillery-2-1/1196/1 "2020-07-31T14:25:58Z")

</div>

I hope this will prove useful for other readers of the book.

I was working through chapter 20 OTP: Applications and run to issues with the example for creating a release using Distillery.

The command _mix release --env=prod_ failed with an error like

> \*\* (Mix) Could not invoke task “release”: 1 error found!  
> –env : Unknown option

Since Elixir 1.9 brings releases directly into Elixir, the _mix release_ -command previously used with distillery now overlaps with the Elixir release command.  
Distillery version 2.1 works with Elixir 1.9 and updates the distillery release command to _mix distillery.release_.

> **[Elixir v1.9 released](https://elixir-lang.org/blog/2019/06/24/elixir-v1-9-0-released/)**
>
> Elixir v1.9 is out with releases support, improved configuration and more.

I made the following changes to be able to locally follow the distillery release example in the book.

Elixir and OTP versions used:

> $ elixir --version  
> Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
> 
> Elixir 1.10.4 (compiled with Erlang/OTP 22)

I don’t have relevant pages as my kindle only shows “locations”, but I have included the section topics.

Section _“Your First Release”_

1 Change dependency to distillery 2.1 in **mix.exs**  
❌ _{:distillery, “~\> 1.5”, runtime: false}_  
✅ _{:distillery, “~\> 2.1”, runtime: false}_

2 Use the updated command for initializing the release  
❌ _mix release.init_  
✅ _mix distillery.init_

3 Create the first release (0.0.1)  
❌ _mix release --env=prod_  
✅ _MIX\_ENV=prod mix distillery.release --env=prod_

This first failed for me (after following the book example) with

> Release failed: could not load /path/config/config.exs

I got around it by adding a minimal config.exs file  
_mkdir config && echo “import Config” \> config/config.exs_

Side note:  
In the book the deploy commands are run with ssh.  
I tried, instead, to run the deploy commands directly from the _\_build -directory_ and found out that consecutive releases don’t work properly that way.

> “I only just noticed that the original issue confirms that this issue was occurring because of running from \_build.”  
> [Successive hot upgrade releases produce error · Issue #160 · bitwalker/distillery · GitHub](https://github.com/bitwalker/distillery/issues/160#issuecomment-279163140)

This might be documented on the distillery documentation, but I haven’t made it there yet.

Section _“A Second Release”_

4 Create the first upgrade release (0.2.0)  
❌ _mix release --env=prod --upgrade_  
✅ _MIX\_ENV=prod mix distillery.release --env=prod --upgrade_

5 Upgrade running code  
This might be because I didn’t use ssh, but instead just copied the archives to separate directory,  
but the command _deploy/bin/sequence upgrade 0.2.0_ failed with

> Node user@host is not running!

To successfully run the upgrade I changed the following:  
Update node name, -name argument, in **rel/vm.args** with the right node name. You can check the node name in the iex console with _Node.self_ command.  
Not sure if relevant, but I updated the _set cookie_ option (environment :prod) in **rel/config.exs** with the value in **~/.erlang.cookie**

Section _“Migrating Server State”_  
6. Create the second release  
❌ _mix release --env=prod --upgrade_  
✅ _MIX\_ENV=prod mix distillery.release --env=prod --upgrade_

That did it for me 😌
