Skip to content

Clojure deps.edn Repositories

The Clojure CLI (tools.deps) reads dependencies from Maven repositories, and a CloudRepo Maven repository is one. There is no separate deps.edn repository type. You need the repository URL in deps.edn, a credential in ~/.m2/settings.xml, and, to publish, deps-deploy.

  • A Maven repository to read from and publish to. Creating a Repository explains how to make one.
  • A repository token that covers it. Choose Download and publish packages when you publish. The token page, Repository Tokens, shows how to mint one. In the settings.xml below, the <username> is the email address that owns the token and the <password> is the token.
  • The repository address, https://your-org.mycloudrepo.io/repositories/your-repo. Its Connection Settings page displays the same address with your organization and repository already filled in.
  • The Clojure CLI and, to publish, deps-deploy. The output quoted on this page comes from Clojure CLI 1.12.4.1602 and deps-deploy 0.2.5.

Used on this page only, never saved. Never enter a token or password here.

1. Put the credential in ~/.m2/settings.xml. tools.deps looks for a <server> whose <id> is the name of the repository in deps.edn. ${env.CLOUDREPO_TOKEN} is filled in from an environment variable when the CLI runs, so the file never holds the token:

~/.m2/settings.xml
<settings>
<servers>
<server>
<id>cloudrepo</id>
<username>you@example.com</username>
<password>${env.CLOUDREPO_TOKEN}</password>
</server>
</servers>
</settings>

2. Name the repository in deps.edn. The key, "cloudrepo", must be the <id> from step 1. The Clojure CLI accepts https:// repository URLs only:

deps.edn
:mvn/repos {"cloudrepo" {:url "https://your-org.mycloudrepo.io/repositories/your-repo"}}

3. Resolve. Add a dependency published to the repository, then run this in the same directory as deps.edn. It downloads the dependencies and anything they need, then stops:

Terminal
clojure -P

Expected: the command ends with no error. The Clojure CLI sends no credential on its first request. CloudRepo replies with 401 and a WWW-Authenticate: Basic header, and the CLI retries with your email and token. If a request trace shows a 401 before each download, that is this auth challenge, not an error.

tools.deps resolves; it does not publish. deps-deploy uploads a jar and its pom.xml to a Maven repository. Build the jar and the pom with tools.build (see its guide), then add an alias to deps.edn. The guide’s build writes the pom inside its class directory, and deps-deploy looks for pom.xml in the directory you run it from, so the alias names the pom with :pom-file. The repository is a map, and the credential comes from two environment variables, not from settings.xml:

deps.edn
:aliases
{:deploy {:replace-deps {slipset/deps-deploy {:mvn/version "0.2.5"}}
:exec-fn deps-deploy.deps-deploy/deploy
:exec-args {:installer :remote
:artifact "target/docs-clj-1.0.0.jar"
:pom-file "target/classes/META-INF/maven/com.example/docs-clj/pom.xml"
:sign-releases? false
:repository {"cloudrepo" {:url "https://your-org.mycloudrepo.io/repositories/your-repo"}}}}}

Run it with the credential set for that one command, using the variables your shell or CI already has:

Terminal
CLOJARS_USERNAME="$CLOUDREPO_USERNAME" CLOJARS_PASSWORD="$CLOUDREPO_TOKEN" clojure -X:deploy

Expected: Deploying com.example/docs-clj-1.0.0 to repository cloudrepo as you@example.com, the files it sends, and done. If the line ends to repository cloudrepo . with no as, no credential reached deps-deploy and CloudRepo will answer 401.

A Maven repository guards its releases unless you turn Overwrite Protection off. A second deploy of a release version answers 409 Conflict, and the copy already stored stays untouched. Versions ending in -SNAPSHOT are exempt. The rules match Maven’s, described in Maven Overwrite Protection.

Raise the version, or switch to a -SNAPSHOT version while you are still iterating.

Invalid repo url (http not supported). The Clojure CLI accepts https:// only. CloudRepo serves https://your-org.mycloudrepo.io.

A private dependency is not found. Check the repository URL, the artifact’s group and name, and make sure the token has access to this repository and has not expired. See Troubleshooting for 401, 403 and 404 checks.

401 Unauthorized while resolving. The <id> in settings.xml is not the key in :mvn/repos, the environment variable is not set in the shell that runs clojure, or the username is the wrong email address: it must be the address that owns the token.

Execution error (UnsupportedOperationException) ... nth not supported on this type: Character when publishing. :repository is a string. deps-deploy 0.2.5 accepts only a map, as in the alias above.

403 Forbidden. The token does not have access to this repository (scope_mismatch_repo), or it has Download packages access and you are publishing. See scope_mismatch_repo.

View as Markdown