adzerk-oss / env Goto Github PK
View Code? Open in Web Editor NEWClojure / ClojureScript environment configuration library.
License: Eclipse Public License 1.0
Clojure / ClojureScript environment configuration library.
License: Eclipse Public License 1.0
For example, in:
(env/def
database_jdbc.url "jdbc:postgresql://..."
database_username "..."
database_password "...")
The first env var in not present when I query it with (env/env)
.
adzerk.boot_cljs.util.proxy$clojure.lang.ExceptionInfo$ff19274a: ERROR: No such namespace: adzerk.env, could not locate adzerk/env.cljs, adzerk/env.cljc, or Closure namespace "adzerk.env" in file...
data: {:tag :cljs/analysis-error,
:file "file.cljs",
:from :boot-cljs}
adzerk.boot_cljs.util.proxy$clojure.lang.ExceptionInfo$ff19274a: No such namespace: adzerk.env, could not locate adzerk/env.cljs, adzerk/env.cljc, or Closure namespace "adzerk.env" in file...
data: {:tag :cljs/analysis-error}
clojure.core/ex-info/invokeStatic core.clj: 4617
clojure.core/ex-info core.clj: 4617
cljs.analyzer$error.invokeStatic analyzer.cljc: 632
cljs.analyzer$error.invoke analyzer.cljc: 628
cljs.analyzer$error.invokeStatic analyzer.cljc: 630
cljs.analyzer$error.invoke analyzer.cljc: 628
cljs.analyzer$analyze_deps.invokeStatic analyzer.cljc: 1774
cljs.analyzer$analyze_deps.invoke analyzer.cljc: 1753
cljs.analyzer$ns_side_effects.invokeStatic analyzer.cljc: 2969
cljs.analyzer$ns_side_effects.invoke analyzer.cljc: 2964
cljs.analyzer$analyze_STAR_$fn__2307.invoke analyzer.cljc: 3059
jumblerg [1:38 PM]
can you think of a reason offhand `adzerk/env` would break with cljs 9? does it depend on some implementation details?
micha [1:39 PM]
yeah
it needs to know if it's being called as a macro or not
``
The env
macro can potentially be harmful when used with clojurescript, by making it easy to mistakenly expose supposedly secret environment vars to the world.
Simply using (env)
in code can will typically result in all environment vars being embedded in the compiled javascript served to the browser. This may include vars supposed to be kept confidential such as secret keys.
However, it is useful to be able to embed environment vars during cljs compile time, particularly for browser apps. I suggest changing the env
macro to require the name of an environment var as argument, and make sure to only inline the value of the specified var in compiled code.
Hey there,
I'm using env/def
to define some env vars with defaults, e.g.
(env/def SERVER_PORT "8080")
I'm running into some trouble using AOT compilation in my boot build task. It seems that once I've AOT'd and uberjar'd my project, these environment definitions get "baked in", if that makes sense. Attempting to set them as follows always results in the default value for the SERVER_PORT
var:
SERVER_PORT=9000 java -jar target/my-project.jar
in my logs:
Starting server on port 8080
I'm guessing that I may be misunderstanding the use of env/def
, and that this is maybe intended behavior...any help would be much appreciated.
There might be some problem either in the README or in the code or in my understanding ๐
I have (env/def SOME_VAR "test)
in my build.boot
but (System.getenv "SOME_VAR")
always returns nil
in the repl. Instead, (System/getProperty "SOME_VAR")
returns "test".
So system prop are defined instead of environment vars but the README states:
the system property of the same name if it is set, or`
...and in my case no property with name SOME_VAR
is not set...
It is not a big deal, but some tool (cprop
) expects different syntax form System properties vs Env vars so it would be cool to address the problem (if any).
Thanks for this very nice tool again!
This is probably some silly error on my part, but I am having trouble getting this to pick up an environmental variable. It says it is not defined, even though it also lists it as defined in it's list of all variables.
This code:
(println (adzerk.env/env))
(adzerk.env/def
CLOJUSH_URI :required)
Produces:
{LEIN_VERSION 2.7.1, HOME /Users/saul, Apple_PubSub_Socket_Render /private/tmp/com.apple.launchd.uLuj5E1bMs/Render, LEIN_FAST_TRAMPOLINE true, USER saul, LEIN_HOME /Users/saul/.lein, gopherProxySet false, TMPDIR /var/folders/67/rgrfj0s939vf1gh0pvdf55ww0000gn/T/, __CF_USER_TEXT_ENCODING 0x1F5:0x0:0x0, XPC_FLAGS 0x0, SHELL /usr/local/bin/fish, TERM_PROGRAM iTerm.app, COLORFGBG 15;0, JVM_OPTS , TERM xterm-256color, LOGNAME saul, SSH_AUTH_SOCK /private/tmp/com.apple.launchd.kc3y1sOCez/Listeners, JAVA_MAIN_CLASS_55194 clojure.main, ITERM_PROFILE Default, PATH /Applications/Genymotion.app/Contents/MacOS/:/Applications/Genymotion Shell.app/Contents/MacOS/:/Users/saul/.local/bin:/Users/saul/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin, ANDROID_HOME /usr/local/opt/android-sdk, SECURITYSESSIONID 186a7, DISPLAY /private/tmp/com.apple.launchd.NoQLnz9aFX/org.macosforge.xquartz:0, TRAMPOLINE_FILE target/trampolines/33f44f5f639a35f17c7a689fc82e8865bcd966da, JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home, XPC_SERVICE_NAME 0, PWD /Users/saul/projects/ici-recorder, LEIN_JAVA_CMD java, TERM_PROGRAM_VERSION 3.1.20170305-nightly, JAVA_CMD java, TIMBRE_LEVEL :trace, ITERM_SESSION_ID w0t1p0:162ACDD3-02EA-4A48-8351-F43545103CC3, LEIN_JVM_OPTS -XX:+TieredCompilation -XX:TieredStopAtLevel=1, SHLVL 1, COLORTERM truecolor, LANG en_US.UTF-8, CLOJUSH_URI alluxio://localhost:19998/clojush/, TERM_SESSION_ID w0t1p0:162ACDD3-02EA-4A48-8351-F43545103CC3}
Exception in thread "main" java.lang.ExceptionInInitializerError, compiling:(/private/var/folders/67/rgrfj0s939vf1gh0pvdf55ww0000gn/T/form-init5236910218834380630.clj:1:5)
at clojure.lang.Compiler.load(Compiler.java:7442)
at clojure.lang.Compiler.loadFile(Compiler.java:7368)
at clojure.main$load_script.invokeStatic(main.clj:277)
at clojure.main$init_opt.invokeStatic(main.clj:279)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invokeStatic(main.clj:310)
at clojure.main$null_opt.invokeStatic(main.clj:344)
at clojure.main$null_opt.invoke(main.clj:341)
at clojure.main$main.invokeStatic(main.clj:423)
at clojure.main$main.doInvoke(main.clj:386)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at clojure.lang.RT.classForName(RT.java:2183)
at clojure.lang.RT.classForName(RT.java:2192)
at clojure.lang.RT.loadClassForName(RT.java:2211)
at clojure.lang.RT.load(RT.java:445)
at clojure.lang.RT.load(RT.java:421)
at clojure.core$load$fn__7846.invoke(core.clj:6008)
at clojure.core$load.invokeStatic(core.clj:6007)
at clojure.core$load.doInvoke(core.clj:5991)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5812)
at clojure.core$load_one.invoke(core.clj:5807)
at clojure.core$load_lib$fn__7791.invoke(core.clj:5852)
at clojure.core$load_lib.invokeStatic(core.clj:5851)
at clojure.core$load_lib.doInvoke(core.clj:5832)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$load_libs.invokeStatic(core.clj:5889)
at clojure.core$load_libs.doInvoke(core.clj:5873)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$require.invokeStatic(core.clj:5911)
at clojure.core$require.doInvoke(core.clj:5911)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at user$eval13$fn__17.invoke(form-init5236910218834380630.clj:1)
at user$eval13.invokeStatic(form-init5236910218834380630.clj:1)
at user$eval13.invoke(form-init5236910218834380630.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6978)
at clojure.lang.Compiler.eval(Compiler.java:6968)
at clojure.lang.Compiler.load(Compiler.java:7430)
... 12 more
Caused by: clojure.lang.ExceptionInfo: Required env vars: [CLOJUSH_URI] {:missing-vars [CLOJUSH_URI]}, compiling:(ici/clojush.clj:21:1)
at clojure.lang.Compiler.load(Compiler.java:7442)
at clojure.lang.RT.loadResourceScript(RT.java:374)
at clojure.lang.RT.loadResourceScript(RT.java:365)
at clojure.lang.RT.load(RT.java:455)
at clojure.lang.RT.load(RT.java:421)
at clojure.core$load$fn__7846.invoke(core.clj:6008)
at clojure.core$load.invokeStatic(core.clj:6007)
at clojure.core$load.doInvoke(core.clj:5991)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5812)
at clojure.core$load_one.invoke(core.clj:5807)
at clojure.core$load_lib$fn__7791.invoke(core.clj:5852)
at clojure.core$load_lib.invokeStatic(core.clj:5851)
at clojure.core$load_lib.doInvoke(core.clj:5832)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$load_libs.invokeStatic(core.clj:5889)
at clojure.core$load_libs.doInvoke(core.clj:5873)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$require.invokeStatic(core.clj:5911)
at clojure.core$require.doInvoke(core.clj:5911)
at clojure.lang.RestFn.invoke(RestFn.java:619)
at ici.test$loading__7732__auto____86.invoke(test.clj:1)
at ici.test__init.load(Unknown Source)
at ici.test__init.<clinit>(Unknown Source)
... 43 more
Caused by: clojure.lang.ExceptionInfo: Required env vars: [CLOJUSH_URI] {:missing-vars [CLOJUSH_URI]}
at clojure.core$ex_info.invokeStatic(core.clj:4725)
at clojure.core$ex_info.invoke(core.clj:4725)
at ici.clojush$eval76.invokeStatic(clojush.clj:21)
at ici.clojush$eval76.invoke(clojush.clj:21)
at clojure.lang.Compiler.eval(Compiler.java:6978)
at clojure.lang.Compiler.eval(Compiler.java:6968)
at clojure.lang.Compiler.load(Compiler.java:7430)
... 68 more
When run with:
env LEIN_FAST_TRAMPOLINE=true CLOJUSH_URI=alluxio://localhost:19998/clojush/ TIMBRE_LEVEL=:trace lein trampoline run
CLOJUSH_URI
shows up in env/env
but it still says it is missing. Any ideas? I am running Clojure 1.9.0-alpha14, Java 1.8.0_112, lein 2.7.1, on macOs 10.12.3.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.