Skip to main content

Getting Started

Let's start using Odyn. Odyn's workflow is intentionally minimal. This page walks you through everything from project creation to importing a dependency in your Odin code.

Checking Odyn's Existence

First, let's check if you actually installed Odyn properly.

odyn --version

This outputs the version of Odyn. Unlike most --version commands, Odyn is context-aware, which means it's different based on your machine. For example, if you installed on a Windows x86_64 machine, it would output the following:

Odyn vX.X.X Windows x86_64
Reproducible vendoring tool for the Odin programming language.

Where X.X.X is your actual Odyn version.

More Outputs

Showcasing Odyn's context-aware version command.

Generic:

Odyn vX.X.X <os> <arch>
Reproducible vendoring tool for the Odin programming language.

Where <os> is your operating system (e.g Android, macOS, Linux) and <arch> is your architecture (e.g. x86_64, aarch64)

Installed from source:

Odyn vX.X.X Nightly, commit <hash> | <os> <arch>
Reproducible vendoring tool for the Odin programming language.

Where <hash> is the git commit hash when you cloned from source.

Installed using Cargo:

Odyn vX.X.X Cargo Edition | <os> <arch>
Reproducible vendoring tool for the Odin programming language.

If that works, then Odyn exists. You're good to go!

Initialize a Project

odyn init myproject
cd myproject

This creates a project layout with src/, odyn_deps/, a pre-configured ols.json, and an empty Odyn.lock.

tip

ols.json is configured out of the box to register odyn_deps/ as a collection called deps, so your editor's autocomplete works immediately without any extra setup. Note that you will need to pass the deps collection to the compiler when building, we'll get to that below.

Add a Dependency

odyn get odin-community/math

This clones the repository into odyn_deps/ and pins its current commit hash to Odyn.lock. By default, odyn get resolves shorthands against GitHub, so the example above resolves to something like https://github.com/odin-community/math. To use another platform:

odyn get bergberg/mathberg --platform codeberg

That resolves it with Codeberg instead, into https://codeberg.org/bergberg/mathberg.

Sync

odyn sync

odyn sync makes odyn_deps/ match exactly what's in Odyn.lock. Run this after cloning a project, pulling changes from a collaborator, or when you recursively remove odyn_deps/. By accident, of course.

Import in Odin

The ols.json that Odyn set up wouldn't even work if you didn't pass the deps collection when building, pass it like so:

odin run src -collection:deps=odyn_deps

Then import any vendored dependency from any file in your project, using deps:

import "deps:math"

What to Commit

Commit Odyn.lock, this is what makes odyn sync reproduce the exact state on any machine.

odyn_deps/ can be safely gitignored, it's fully reproducible from the lockfile. That said, committing it too is valid if you prefer everything self-contained in the repo. I recommend committing odyn_deps/ in the case that a repo that the lockfile is pointing to is made inaccessible.