Minimal Ash 2.x Setup Guide

There are a couple of steps we need to do for every new mix project which uses Ash. This guide will walk you through those steps. For this book we use the very generic name app for the application. Please use a more meaningful name for your own applications. We keep using App in this guide to make it easier to mix and match seperate parts of this book if you want to.

To use app as the default application name in this book has one major drawback: You have to either rename old project directories or delete them when creating a new one. Alternatively you can change the appname with all examples to something like app2, 'app2', 'foobar', etc.

Let’s start with a fresh Mix project:

$ mix new --sup app
$ cd app

We change the dependency in mix.exs to add Ash (find the latest Ash version number at https://hex.pm/packages/ash):

mix.exs
[...]
defp deps do
  [
    {:ash, "~> 2.15.8"} # Add this line
  ]
end
[...]

Run mix deps.get to install it:

$ mix deps.get

To make sure that we get the right formatting for our code, we change the file .formatter.exs to include the Ash formatter:

.formatter.exs
[
  # add the next line
  import_deps: [:ash],
  inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
The Elixir formatter is a great tool to keep your code consistent. It is highly recommended to use run the command mix format before committing your code into a repository.