veimis

veimis

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

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.

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
:x: {:distillery, “~> 1.5”, runtime: false}
:white_check_mark: {:distillery, “~> 2.1”, runtime: false}

2 Use the updated command for initializing the release
:x: mix release.init
:white_check_mark: mix distillery.init

3 Create the first release (0.0.1)
:x: mix release --env=prod
:white_check_mark: 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

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)
:x: mix release --env=prod --upgrade
:white_check_mark: 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
:x: mix release --env=prod --upgrade
:white_check_mark: MIX_ENV=prod mix distillery.release --env=prod --upgrade

That did it for me :relaxed:

Where Next?

Popular Pragmatic Bookshelf topics Top

telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
gilesdotcodes
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions: In Gemfile, change gem 'rails' t...
New
AndyDavis3416
@noelrappin Running the webpack dev server, I receive the following warning: ERROR in tsconfig.json TS18003: No inputs were found in c...
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New

Sub Categories: