# MixInstallExamples shows what a single-file Elixir script can do

> The mix_install_examples repository is a shelf of small Elixir scripts that each pull their own dependencies with `Mix.install/2`, covering everything from Absinthe to Phoenix LiveView, so you can read one working example of a library before adding it to a project. It suits people learning Elixir or evaluating a library without a project around it.

**wojtekmach/mix_install_examples** — A collection of simple Elixir scripts that are using Mix.install/2.

- Repository: https://github.com/wojtekmach/mix_install_examples
- Stars: 795 · Forks: 58
- Language: Elixir
- License: not declared
- Published: 2026-10-20 · Updated: 2026-10-20 · Language: en
- Canonical page: https://hysenlabs.com/projects/wojtekmach-mix-install-examples

## One file, one library, dependencies resolved at run time

The repository is described in one line as a collection of simple Elixir scripts that are using `Mix.install/2`, and it requires Elixir v1.12 or later. The mechanism is what makes the collection work. Instead of a `mix.exs`, a `deps/` directory and a `mix deps.get` step, a script declares the libraries it needs at the top and the Mix task fetches and compiles them into a temporary environment before the script runs. That is why the examples are single files, why the repository needs no project structure, and why you can run one from a clone with nothing but an Elixir installation. It also means each example is a self-contained, readable statement of how that library is used, which is the actual point of the collection.

## The Benchee example, in full

The README walks through one example end to end, and it is worth reading because it shows the shape of every other script. The `benchee.exs` file uses the Benchee benchmarking library, and the whole script is short:

```elixir
Mix.install([
  {:benchee, "~> 1.0"}
])

list = Enum.to_list(1..10_000)
map_fun = fn i -> [i, i * i] end

Benchee.run(
  %{
    "flat_map" => fn -> Enum.flat_map(list, map_fun) end,
    "map.flatten" => fn -> list |> Enum.map(map_fun) |> List.flatten() end
  },
  time: 10,
  memory_time: 2
)
```

Two anonymous functions are compared, `Enum.flat_map` against a `map` piped into `flatten`, over a list of ten thousand integers. The dependency declaration is the first thing in the file and the version constraint is a normal requirement string, `~> 1.0`. Everything after it is ordinary library usage with no project context to decode.

## Running an example is three commands

The workflow the README describes is deliberately minimal. You clone the repository, change into the directory, and look at the script:

```bash
git clone https://github.com/wojtekmach/mix_install_examples.git
cd mix_install_examples
cat benchee.exs
```

Then you run it with the Elixir interpreter directly, no mix project and no `mix deps.get`:

```bash
elixir benchee.exs
```

The output the README shows is the Benchee report itself, with the operating system, CPU information, the number of cores, available memory, and the Elixir and Erlang versions in use, followed by the benchmark suite configuration and the two functions timed. The comparison line is the useful part, with `flat_map` at 4.44 K iterations per second against `map.flatten` at 2.68 K, described as 1.65x slower, and a second block of memory usage statistics. The numbers are from the author's machine and are illustrative of what the output looks like, not a claim about your hardware.

## The catalogue, by library name

The repository root is the index, because every example is a file named after the library it demonstrates. The listing runs from `absinthe.exs` and `absinthe_plug.exs` through `ash.exs`, `ash_json_api.exs`, `bandit.exs`, `beam_file.exs`, `brotli.exs`, `bypass.exs`, `dagger.exs`, `datix.exs`, `decompilerl.exs`, `deno_ex.exs`, `easyxml.exs`, `ecto_sql.exs`, `erqwest.exs`, `eventsource_ex_chatgpt.exs`, `ex_audit.exs`, `ex_aws_s3.exs`, `ex_doc.exs`, `ex_webrtc.exs`, `exla.exs`, `explorer.exs`, `exshome.exs`, `ezstd.exs`, `finch.exs`, `fs.exs`, `gen_stage.exs`, `glob_ex.exs`, `gun.exs`, `html5ever.exs`, `httpoison.exs`, `katipo.exs`, `localize.exs`, `mint.exs`, `mint_websocket.exs`, `mneme.exs`, `myxql.exs`, `nanoid.exs`, `nimble_csv.exs`, `nimble_publisher.exs`, `oban.exs`, `objc.exs`, `off_broadway_telegram.exs`, `otter.exs`, `pacer.exs`, `phoenix.exs`, `phoenix_live_view.exs` and its bootstrap, upload image and websocket variants, `plug_cowboy.exs`, `plug_websocket.exs`, `postgrex.exs`, `postgrex_notifications.exs` and `protox.exs`. The spread is the point, from GraphQL servers to SQL clients to embedded browsers.

## What the collection is for, and what it is not

The use case is narrow and legitimate. When you are evaluating a library, the hardest part is often the first twenty lines, and the second hardest is finding an example that matches your version. A file that installs its own dependency and runs on its own answers both. It is also the cheapest possible way to try a library, because a script that downloads its own dependencies can be run on a machine with nothing but Elixir installed. What it is not is a testbed for a real application. There is no `mix.exs`, no supervision tree, no configuration layer and no dependency pinning across the collection, so an example that works today may break with the next release of the library it demonstrates. The `.formatter.exs` file in the root suggests the scripts are kept in the standard Elixir formatting style, which is a small sign of care but not of a release process.

## Licence, maintenance and the state of the collection

Two facts about the repository are worth stating plainly. No licence is identified in the project metadata, so the terms for copying these scripts into your own code are not stated, and for a collection whose whole purpose is to be copied from, that is a gap rather than a technicality. There are also no GitHub releases, so there is no version to track, and the last push to the repository was on 2026-04-13, which means the examples are a snapshot of the libraries as they were around then rather than a maintained set. The examples remain useful in that state, because the shape of an integration does not change as fast as the versions do, but the version constraints in each `Mix.install` call are the first thing to check, and the code is a starting point for you to rewrite rather than a dependency to install.

## Conclusion

Adopt this collection as a reference library rather than a dependency, because the value is in reading one runnable file per library and seeing the minimum code that makes it work with Mix.install. Do not put it in a production dependency list, since the scripts are examples, they are not published as a package, and the repository does not state a licence. Verify first that the example you care about is present, since the catalogue is a flat list of scripts named after their libraries, and note that the collection was last pushed to on 2026-04-13, so a library that has moved on since then will have an example that no longer matches current releases.

## FAQ

### What is Mix.install/2 and why does the repository use it?

It lets a script declare the libraries it needs so Mix fetches and compiles them into a temporary environment before the script runs. That is why every example here is a single file with no project structure, no mix.exs and no dependency directory.

### How do I run one of the mix_install_examples scripts?

Clone the repository, change into the directory, and run the script with the interpreter directly, for example `elixir benchee.exs`. The README shows the clone, `cd` and `cat benchee.exs` steps before that.

### Which libraries are covered by the examples?

The repository root lists one script per library, including Absinthe, Ash, Bandit, Dagger, Ecto SQL, ExDoc, Finch, Gun, HTTPoison, Mint, Oban, Phoenix, Phoenix LiveView, PostgREST's client, Protox and many more, with the listing visible in the top level entries.

### Do I need a mix project to use these examples?

No. The scripts are run directly with the Elixir interpreter, and each one installs its own dependencies at run time. The README states that Elixir v1.12 or later is required.

## Sources

- [Issues](https://github.com/wojtekmach/mix_install_examples/issues)
- [README](https://github.com/wojtekmach/mix_install_examples/blob/main/README.md)
- [wojtekmach/mix_install_examples on GitHub](https://github.com/wojtekmach/mix_install_examples)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/wojtekmach-mix-install-examples
