gleam-lang/gleam

Add git deps with `gleam add`

Open

#5678 opened on May 3, 2026

View on GitHub
 (1 comment) (0 reactions) (1 assignee)Rust (21,417 stars) (960 forks)batch import
help wanted

Description

As previously discussed here: #5619.

We can add a --git flag to gleam add to denote that we want to install the package from Git instead of Hex. For example:

gleam add --git https://github.com/gleam-lang/stdlib

The default behaviour is that the tip of the default branch is used. An optional --ref flag will let the user specify which branch, tag, or commit they want to use. This is, as I said in the original discussion post, essentially identical to the syntax used in gleam.toml to represent Git deps.

# branch
gleam add --git https://github.com/lustre-labs/ui --ref headless-redux-redux

# commit
gleam add --git https://tangled.org/haripm.com/snowball_stemmer -r a2dc4eff

# tag
gleam add --git ssh://git@git.:/some/path --ref v1.0.1

Note for the future

Once support for monorepos/path field in git deps (#5632) is merged, we should also add an optional --path field (as suggested by @GearsDatapacks) that lets users specify where in the repository the package they want lives. Right now, with single-package repos, we can use the gleam.toml at the repo root to identify the package name.

Re. monorepo support: I checked how Cargo does it again; instead of supporting a --path flag, you instead specify the package name right after cargo add, and the corresponding package is fetched from the crates directory. However, I think a flag is more consistent with the overall design, especially since Gleam does not have a similar established convention for monorepos (yet) (#5653).

I am starting work on this! Let me know if we want any changes to this design.

Contributor guide