Comments (11)
With Environ I prefer to distinguish between the process environment, which is static, and the program's configuration, which may change. Conflating the two leads to inadvertent complexity.
For REPL development it's often more useful to work with the configuration directly. For example, in user.clj
you might have:
(def user-config
{:port 3000})
(def user-system
(new-system user-config))
(defn start []
(component/start user-system))
While your -main function might be defined:
(def env-config
{:port (Integer. (:port env))})
(def main-system
(new-system env-config))
(defn -main [& args]
(component/start main-system))
The -main function derives its configuration from the environment, but the configuration is distinct from the environment.
from environ.
Thats a very good point :) I still think there is room for developer specific configuration, but maybe just a read
on a separate file would be better for that.
from environ.
Why not define the developer configuration in a local user.clj
?
from environ.
been checking in project user.clj. is that a bad idea?
from environ.
Ah, you mean a local configuration, out of version control. Perhaps a local.clj
as well (excluded from the VCS), to complement user.clj
? That would allow devs to add in their own alterations to the dev environment, as well as setting up local configurations.
from environ.
yeah, that makes loads of sense :)
from environ.
eviron still reads ".lein-env". Why cannot I do the same and load additional data from my own configuration file (I think of updating System/getProperties from additional file) ?
Maybe dispense with environ.core/env var and make it a function? If anyone cares about efficiency it's possible to defonce resulting value it in user code or use let binding.
from environ.
Environ isn't a library for reading configuration files; it's a tool for accessing the environment the process has started in. The .lein-env
file is just a mechanism to allow the environment to be set from Leiningen.
from environ.
Of course it's not for reading files. I am happy to read that file and update System/getProperties in my code. But if I do that it won't affect env value because it is already initialized. If env is a function then I can construct and update it's resulting value however I need.
Having env value defonced forces me to gather additional external configs elsewhere what kind of defeats the purpose of unifying them with this library.
from environ.
The purpose of the lib is to handle environment configuration which may be set at several levels. After this PR i realized what i really wanted was (merge env (read-str (slurp "./config.clj")))
, which isnt what environ is trying to tackle.
from environ.
Having env value defonced forces me to gather additional external configs elsewhere what kind of defeats the purpose of unifying them with this library.
That's not the purpose of this library. This library is designed to provide access to the process environment, it's not a library for reading configuration.
The .lein-env
file is just an implementation detail that may disappear in future, if a better solution for getting information from active project map presents itself.
from environ.
Related Issues (20)
- boot-environ/environ weird precedence HOT 2
- lein run HOT 1
- sanitize function strips keyword namespace HOT 2
- dynamic system properties HOT 1
- NodeJS compatibility HOT 3
- creating of shell script for environment HOT 1
- FileNotFoundException thrown when .lein-env file is not found HOT 1
- Why cast to string? HOT 6
- Use vector as environment variable HOT 2
- File .lein-env is emptied by lein uberjar command HOT 6
- Environ values with identical keys are silently overwritten HOT 1
- .boot-env file causing errors when starting from uberjar HOT 4
- Override dev config w/ env vars HOT 2
- update clojure version to 1.9.0 HOT 4
- Lein 2.8.2 warns about deprecated hook lein-environ.plugin/hooks HOT 12
- lein test merges test into dev? HOT 2
- <project>-version key is nil in uberjar HOT 2
- IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol HOT 2
- Consider exposing 'read-env' HOT 2
- Consider configurable logging
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from environ.