In Leiningen configuration, how can I use environment variables to export the username?

This question is related to this previous question.

I am able to install private Maven packages available on GitHub packages with the following setting on project.clj:


  :repositories {"releases"  {:url           "*"
                              :username      "pdelfino"
                              :password      :env}}


As you see, I can already use environment-variables for the password, since it was set on my .zshrc file:

export LEIN_PASSWORD="my-personal-access-token-which-will-not-be-shared"

I would like to do the same for the username! This would be particularly important since other folks are working on this project.

I tried a few things, but none of them worked out. One example of documentation only illustrates how to do it with the password (using LEIN_PASSWORD - see here) but does not solve the username part. Executing lein help sample generates the same content previously mentioned.

How do I fix this?


  • As suggested by @cfrick in a comment, the solution was adding the snippet below on my .zshrc file, use the pointer on project.clj, and re-starting the terminal:

      :repositories {"releases"  {:url           "*"
                                  :username      :env/LEIN_USERNAME 
                                  :password      :env/LEIN_PASSWORD}}
    export LEIN_USERNAME="pdelfino"
    export LEIN_PASSWORD="my-personal-access-token-which-will-not-be-shared"

    I tried that earlier today. But, forgot to re-start the terminal (iTerm2).