This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-20
Channels
- # adventofcode (140)
- # beginners (107)
- # boot (120)
- # boot-dev (1)
- # clara (13)
- # cljs-dev (9)
- # clojure (107)
- # clojure-argentina (5)
- # clojure-art (16)
- # clojure-dev (23)
- # clojure-greece (19)
- # clojure-italy (5)
- # clojure-russia (2)
- # clojure-serbia (3)
- # clojure-spec (27)
- # clojure-sweden (1)
- # clojure-uk (15)
- # clojurescript (134)
- # cursive (5)
- # data-science (10)
- # datomic (23)
- # duct (28)
- # fulcro (48)
- # garden (5)
- # hoplon (2)
- # instaparse (1)
- # klipse (7)
- # leiningen (8)
- # lumo (36)
- # off-topic (72)
- # om (4)
- # onyx (37)
- # perun (4)
- # re-frame (64)
- # reagent (86)
- # remote-jobs (1)
- # shadow-cljs (59)
- # spacemacs (16)
- # sql (1)
- # uncomplicate (6)
- # unrepl (90)
Does boot have something equivalent to https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies ?
I'd like to test some changes that I made to a dependency locally, and was wondering how I'd link it to my project
anyone know how to get https://github.com/hashobject/boot-s3 to work with boot-environ?
I want to grab my aws keys from env vars during a task
@bostonaholic boot-environ is deprecated -- did you read the underlying environ README showing how to use it with Boot? (I haven't tried it -- just asking)
@aj I asked Bing clojure boot checkout dependencies
š
Iām using boot-environ from https://github.com/weavejester/environ
which seems to be the replacement
@bostonaholic Cool, yeah, looks like it got folded in.
I canāt figure out how to get enviro to pick up .boot-env
and allow me to (env :aws-access-key)
for instance
so I can pass that as an arg to s3-sync
task
Are you sure .boot-env
is on your classpath?
that might just be it
Hmm, according to the README, it sounds like .boot-env
is generated by the environ
task...?
yeah, that doesnāt make sense to me
it shouldnāt be
that wouldnāt make any sense
Ah... because tasks in the pipeline might want to read it from the fileset perhaps? And you might want to pass the values via the command line (the -e
argument to the environ
task) or via actual code (the environ
task with an :env
argument)? It does seem a bit odd.
Iāve used environ plenty of times with lein but I canāt get it to work with boot
OK, I just tried it at the command line -- not clear from the README but the boot-environ
dependency is purely for the Boot task that sets environment variables into .boot-env
. The environ
dependency is for the environment variable reading part it seems.
sean@sean-xps:~/clojure$ boot -d environ:1.1.0 -d boot-environ:1.1.0 environ -e foo=bar repl
...
boot.user=> (require '[environ.core :refer [env]])
nil
boot.user=> (env :foo)
"bar"
boot.user=>
that makes sense
I think I have to figure out if/how to put .boot-env
in the classpath
That's generated by the boot-environ
part.
It sounds like you want to invoke the s3-sync
task, passing environment variable values as arguments?
So you only need environ
, not boot-environ
, since you only want to read from the environment...
when I use lein-environ, I have a .lein-env
file that looks like {:database-url ...}
so I can (environ.core/env :database-url)
in my code
Let me try creating a .boot-env
file then just to test that...
I canāt figure out how to get the .boot-env
in the classpath so environ can read from it
Got it working ...
sean@sean-xps:~/clojure$ echo '{:foo "bar"}' > .boot-env
sean@sean-xps:~/clojure$ boot -d environ -d boot-environ -s . call -p -e "(require '[environ.core :refer [env]])" -e '(env :foo)'
Classpath conflict: org.clojure/clojure version 1.9.0-RC1 already loaded, NOT loading version 1.5.1
nil
bar
sean@sean-xps:~/clojure$ FOO=WAT boot -d environ -d boot-environ -s . call -p -e "(require '[environ.core :refer [env]])" -e '(env :foo)'
Classpath conflict: org.clojure/clojure version 1.9.0-RC1 already loaded, NOT loading version 1.5.1
nil
WAT
I could probably use -r
for :resource-paths
instead of -s
for :source-paths
but actual environment variables override the contents of .boot-env
it seems (good!).
The Nope, just tried without .boot-env
file is only picked up if you add the boot-environ
dependency.boot-environ
and it does find it...
So I think that confirms that boot-environ
is only needed to write to .boot-env
I think, so you can manipulate the environment via the task.
hmmm, I must be missing something
(deftask try-env []
(prn (-> env keys sort))
(prn "============" (env :aws-access-key))
identity)
that is my testing task that (env :aws-access-key)
returns nil
when I boot try-env
from cli
env
is a function so (-> env keys sort)
won't work
env
is a hashmap
it prints out all the rest of my env vars
but doesnāt include the ones Iāve added in .boot-env
Oops, yeah, sorry... my command line was wrong...
Well, I put {:foo "BAR"}
in .boot-env
and with -r .
it found it just fine.
any idea how to tell build.boot
to add .boot-env
to the classpath?
-r .
or (merge-env! :resource-paths #{"."})
assuming it's in the top-level of your project
getting closer
And the environ
task combines with whatever's in .boot-env
:
sean@sean-xps:~/clojure$ echo '{:foo "bar"}' > .boot-env
sean@sean-xps:~/clojure$ boot -d environ -d boot-environ -r . environ -e bar=cmd-line call -p -e "(require '[environ.core :refer [env]])" -e '(-> env keys sort)' -e '(env :foo)' -e '(env :bar)'
Classpath conflict: org.clojure/clojure version 1.9.0-RC1 already loaded, NOT loading version 1.5.1
nil
(:awt-toolkit :bar :boot-app-path :boot-class-path :boot-file :fake-class-path :file-encoding :file-encoding-pkg :file-separator :foo :home ...)
bar
cmd-line
I put .boot-env
into resource paths and it worked
but now I have to figure out a better way
(merge-env! :resource-paths #{"."})
results in āAssert failed: The :source-paths, :resource-paths, and :asset-paths must not overlap.ā
Right, that was just an example given that I'm using just the command line and have no build.boot
file.
The .boot-env
file can either be in the :source-paths
locations or the :resource-paths
locations to be on the classpath.
You don't need .boot-env
at all if you just want to read from actual environment variables...
yeah, I know. thatās how I have ci set up
but this is for local so I can save creds
So .boot-env
can be anywhere -- you just need to merge its path into either resource paths or source paths.
I just put it in resources/
because if itās in .
I keep getting Assert failed: The :source-paths, :resource-paths, and :asset-paths must not overlap.
:source-paths #{"src"}
:asset-paths #{"html"}
:resource-paths #{"."}
for instance
Yes, you would get that assertion -- as I noted above.
But it can also be outside your project and use a path like "../ci-env"
so it would read ../ci-env/.boot-env
thanks for your help @seancorfield
itās weird that it behaves slightly different than lein-environ
Boot is very different to Leiningen š
We switched almost two years ago...
to boot?
Iāve only used boot for very small projects, not large apps
We have a mono-repo with over a dozen subprojects all managed with Boot...
About 75,000 lines of Clojure, including tests.
Our build.boot
is well over 1,000 lines š
yikes
I work with Phil so I doubt weāll be switching away from leiningen anytime soon š
(although Iām sure heād be for it if it made sense)
We just needed to do stuff that was hard to do in Leiningen plugins. We needed things more dynamic.
For example, we do source code analysis with tools.namespace
to determine inter-project dependencies and automatically build the :source-paths
on the fly.
ugh, I canāt put .boot-env
in :resource-paths
otherwise it ends up in my distribution
glad I checked that before syncing to s3
That means we can refactor code across subprojects without needing to change anything in the build.
Do you mean s3-sync
sucks up everything in your :resource-paths
? That seems unfriendly. Such things wouldn't go into the JAR file...
it sucks up from target-path
@bostonaholic The s3-sync
task accepts a :source
argument and should only upload that directory?
https://github.com/weavejester/environ/blob/master/environ/src/environ/core.clj#L42-L43
I think the bug is in the second line
for lein-env it uses io/file
but boot-env using io/resource
so boot-env has to be in resources to be picked up
but lein-env can be at the root of the fs
It's not a bug -- it's doing exactly what the README says it should.
youāre right, it does say āon the classpathā in the readme
wonder why itās differentā¦
Because that's in line with how Boot works.
If the S3 task syncs a folder in the target path, you can probably use sift
to move everything except .boot-env
to that folder.
what is sift?
A Boot task to move stuff around in the fileset.
do you have a link? Iām not finding it anywhere
boot sift -h
ah, of course
I was looking in the wiki
I would imagine you can exclude .boot-env
with sift -i .boot-env -v
@bostonaholic Let me know how it works out in the end. And thank you for the chance to learn about environ
and boot-environ
š
Thanks for all of your help the other night. Hereās how it ended.
(set-env!
:source-paths #{"src" "dev"}
:dependencies '[...
[environ "1.1.0" :scope "test"]
...])
(require
...
'[environ.core :refer [env]]
...)
(deftask build
"Build distribution."
[]
(comp
(cljs :optimizations :advanced
:source-map true)
(sift :include #{#".boot-env"}
:invert true)
(target :dir #{"target"})))
(deftask deploy
"Deploy distribution"
[]
(s3-sync :source ""
:bucket (env :aws-bucket)
:access-key (env :aws-access-key)
:secret-key (env :aws-secret-key)))
ended up putting .boot-env
in ./dev
Nice!
:thumbsup:
thanks A TON for all of your help
still some fiddling Iāve got to do, but itās getting very close
granted, deploys work on ci and Iām just trying to get them to work locally
If you're interested in reading more about our experiences with Boot http://seancorfield.github.io/blog/categories/boot/
(conj reading-list *1)
We've had Clojure in production since 2011. We have 1.9.0 in production (as of today -- we were on prerelease builds before that). We use clojure.spec
fairly heavily š
Iām at CircleCI and use all of those as well, just not boot
For most of our processes, we use Boot tasks to build uberjars, but we also still use Boot directly in production for some stuff...
Ah, CircleCI is a very cool company!
indeed it is