{"id":19917194,"url":"https://github.com/athos/lein-with-env-vars","last_synced_at":"2025-06-18T09:33:21.450Z","repository":{"id":62433381,"uuid":"54311331","full_name":"athos/lein-with-env-vars","owner":"athos","description":"A Leiningen plugin for performing a task with environment variable settings loaded from project.clj","archived":false,"fork":false,"pushed_at":"2019-09-02T13:44:52.000Z","size":17,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-03T06:44:53.417Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/athos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-20T10:14:15.000Z","updated_at":"2024-08-27T12:28:51.000Z","dependencies_parsed_at":"2022-11-01T21:16:03.043Z","dependency_job_id":null,"html_url":"https://github.com/athos/lein-with-env-vars","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/athos/lein-with-env-vars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Flein-with-env-vars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Flein-with-env-vars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Flein-with-env-vars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Flein-with-env-vars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/athos","download_url":"https://codeload.github.com/athos/lein-with-env-vars/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athos%2Flein-with-env-vars/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260527245,"owners_count":23022722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T21:49:06.495Z","updated_at":"2025-06-18T09:33:16.436Z","avatar_url":"https://github.com/athos.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lein-with-env-vars\n[![Clojars Project](https://img.shields.io/clojars/v/lein-with-env-vars.svg)](https://clojars.org/lein-with-env-vars)\n\nA Leiningen plugin for performing a task with environment variable settings loaded from project.clj\n\n## Installation\n\nAdd the following line into the `:plugins` vector of an appropriate profile.\n\n[![Clojars Project](https://clojars.org/lein-with-env-vars/latest-version.svg)](https://clojars.org/lein-with-env-vars)\n\n## Usage\n\nFirst, add `:env-vars` map to specify the environment variable settings in your `project.clj`\nlike the following:\n\n```clj\n(defproject foo-bar\n\n  ...\n\n  :env-vars {:ENV_VAR_FOO \"foo/bar/baz\"}\n\n  ...  )\n```\n\nAnd then, run a task with `with-env-vars` to set the environment variables according to the settings:\n\n```clj\n$ lein with-env-vars repl\n...\nuser=\u003e (System/getenv \"ENV_VAR_FOO\")\n\"foo/bar/baz\"\nuser=\u003e\n```\n\nYou can also specify a string or a vector of strings instead of a map to the `:env-vars` key.\nIn that case, those will be interpreted as the name of files containing environment variable settings.\n\nFor instance, say you have a file named `.env-vars` whose content is as follows:\n\n```clj\n{:ENV_VAR_FOO \"foo/bar/baz\"}\n```\n\nAnd if you specify `[\".env-vars\"]` to the `:env-vars` key in `project.clj`,\nthen `lein with-env-vars repl` will work exactly as the above example:\n\n```clj\n(defproject foo-bar\n\n  ...\n\n  :env-vars [\".env-vars\"]\n\n  ...  )\n```\n\n### Leiningen hooks\n\nThis plugin also provides Leiningen hooks to inject environment variables automatically.\n\nTo enable the hook, add `leiningen.with-env-vars/auto-inject` to `:hooks` key:\n\n```clj\n(defproject foo-bar\n\n  ...\n\n  :hooks [leiningen.with-env-vars/auto-inject]\n\n  ... )\n```\n\nOnce you specify the hook, no need to use the `with-env-vars` higher-order task explicitly.\nEvery time you run a Leiningen task, the specified environment variables will be injected automatically.\n\n**Note** This hook mechanism is useful, but could also be problematic in some cases.\nIf the hook is enabled and a file name is specified to the `:env-vars` key, the hook always\nchecks whether the file exists (and if not, it will fail) every time you run a Leiningen task.\n\nSee also [the example project](examples/example) to see how to use the plugin in a practical project.\n\n## Why not use Environ?\n\n[Environ](https://github.com/weavejester/environ) (or lein-environ) is another tool for managing environment settings.\n\nThough it supports environment variables as one of its setting sources, Environ does **NOT** actually set environment variables when starting a task process. So, for example, if you want to use a library that requires a certain environment variable to be set, it wouldn't work suitably.\n\n## License\n\nCopyright © 2016 OHTA Shogo\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathos%2Flein-with-env-vars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathos%2Flein-with-env-vars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathos%2Flein-with-env-vars/lists"}