8

I cannot get leiningen to download the datomic-pro peer library. I have the following setup:

~/.lein/credentials.clj.gpg

{#"my\.datomic\.com" {:username "..."
                      :password "..."}}

And the project

(defproject datomic-example "0.1.0-SNAPSHOT"

  :repositories {"my.datomic.com" {:url "https://my.datomic.com/repo"
                                   :creds :gpg}}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [com.datomic/datomic-pro "0.9.4956"]])

I install gpg via brew install gpg, then running lein deps gives me the following error:

Could not decrypt credentials from /Users/.../.lein/credentials.clj.gpg
gpg: no valid OpenPGP data found.
gpg: decrypt_message failed: eof

See `lein help gpg` for how to install gpg.
(Could not transfer artifact com.datomic:datomic-pro:pom:0.9.4956 from/to my.datomic.com (https://my.datomic.com/repo): Not authorized , ReasonPhrase:Unauthorized.)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.

NOTE: I created a pom.xml / settings.xml as described on the homepage and that worked immediatly with maven. I also know that I can install the peer library directly from datomic/bin/maven-install, but I would prefer a plain leiningen install.

Alex Miller
  • 69,183
  • 25
  • 122
  • 167
shaft
  • 2,147
  • 2
  • 22
  • 38

2 Answers2

12

I had a bunch of problems with that too. Depending on what OS you're running on it varies. One thing that worked for me was using env vars rather than the gpg route.

Add this to your environment vars (.bashrc file is the easiest on unixy OSs)

export MY_DATOMIC_USERNAME="your@email.com"
export MY_DATOMIC_PASSWORD="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Reload bash and check that they are there:

$  echo $MY_DATOMIC_USERNAME
your@email.com

Then add this to your project.clj file:

:repositories [["my.datomic.com" {:url "https://my.datomic.com/repo"
                        :username [:env/my_datomic_username]
                        :password [:env/my_datomic_password]}]]

And of course add whichever version you want to your dependencies eg:

[com.datomic/datomic-pro "0.9.4815.12"]

After a lein deps you should have loaded the libs you need.

Hope this helps.

adamneilson
  • 758
  • 7
  • 9
  • 1
    Tried this and I am still getting this: "Could not transfer artifact com.datomic:datomic-pro:pom:0.9.5206 from/to my.datomic.com (https://my.datomic.com/repo): Not authorized , ReasonPhrase:Unauthorized. This could be due to a typo in :dependencies or network issues. If you are behind a proxy, try setting the 'http_proxy' environment variable." – letronje Sep 03 '15 at 04:00
  • @letronje did you ever figure it out? I get the same thing running on a vagrant – Kendall Jul 07 '16 at 15:35
4

I found this: https://github.com/technomancy/leiningen/blob/master/doc/DEPLOY.md#gpg

Where you create a ~/.lein/credentials.clj file with your credentials:

{#"my\.datomic\.com" {:username "USERNAME"
                      :password "PASSWORD"}}

And then encrypt it with gpg:

$ gpg --default-recipient-self -e ~/.lein/credentials.clj > ~/.lein/credentials.clj.gpg

Worked for me, I hope it helps

Konrad
  • 41
  • 3
  • 1
    I had to run `gpg --gen-key` before this would work for me (after `brew install gpg`) – Adam Mar 11 '15 at 01:16