Fork me on GitHub

Hey, i have a question on accessing environment variables in project.clj and hope someone can help me out: I am writing a lein plugin, and i need to read something like {:config :env/CONFIG_A} in project.clj, but couldnt get it work. Looking at other projects (lein plugins) but I couldnt figure out how this works


Can you explain a bit further? I use lein-environ for env stuff, but I think it’s a bit different to what you’re wanting to do


@danielcompton basically, i have seen something like this {:user-name :env/USER_NAME} in project.clj, and it got picked up as environment variables


but i just couldnt figure out how that worked


That will be plugin specific I expect


but you would iterate over the kv in your config, check each value to see if it is a keyword, and if so if it's namespace is env


If so, then use (System/getEnv.. to look up the name of the keyword


> "Keywords with a project namespace are looked up in the project map. For example:"


but AFAICT this is specific to repositories, not a general functionality that you can use anywhere in project.clj


The philosophy of Leiningen is to lean towards repeatable builds, so generally you only want environment variables for things that shouldn’t be stored in code, e.g. passwords