Fork me on GitHub
#tools-deps
<
2018-11-01
>
borkdude09:11:14

Is it possible to combine multiple R aliases into one alias?

dominicm09:11:01

How do you mean?

borkdude09:11:39

Say alias A says extra deps d1 d2, alias B says extra deps d3 d4, now I want to make an alias AB which combines A and B so it has extra deps d1 .. d4

borkdude09:11:03

Basically wondering if I could do something like https://github.com/borkdude/boot-bundle using deps.edn

dominicm10:11:48

@borkdude there's no inheritance. So the only way to do it is by modifying the edn file. I've been writing https://github.com/SevereOverfl0w/ednup with the goal of it eventually supporting this.

timgilbert16:11:03

Say, I'm trying to figure out how to effectively deal with the .cpcache directory in circleci. The way it works is that circleci can store a directory in a cache which is then available to subsequent steps (although the subsequent steps might themselves run on different VM instances).

timgilbert16:11:51

So what I currently do is run clojure -A:foo:bar -Spath to download a bunch of stuff and then cache the .m2 and .cpcache directories

timgilbert16:11:51

My question is, will tools.deps create a single .cpcache entry for the combined :foo:bar aliases, or will it create a :foo cache and a :bar cache? (Or all three?)

timgilbert16:11:25

I'm wondering if it would be more efficient to run clojure -A:foo -Spath; clojure -A:bar -Spath

Alex Miller (Clojure team)16:11:37

the cache key is based on the set of aliases used

timgilbert16:11:56

Aha, makes sense. Thanks @alexmiller

fmjrey17:11:27

Hey, I'm migrating some lein project to deps.edn and somehow it looks like my dev/user.clj isn't loaded in the repl, even though I use clj -R:dev and the :dev alias does have :extra-paths ["dev" "fixtures"]. My user.clj is very simple:

(:require
   [com.stuartsierra.component.user-helpers :refer [dev go reset]]))
clj -Stree -R:dev shows the component lib is loaded. Still it's as if user.clj isn't loaded:
$ clj -R:dev dev/user.clj
$
No output or error.
$ clj -R:dev
Clojure 1.9.0
user=> (dev)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: dev in this context, compiling:(NO_SOURCE_PATH:1:1) 
user=> 
What could I be missing?

hiredman17:11:07

use -A not -R

👌 4
😊 4
fmjrey17:11:55

Thanks, feel stupid now, wondering how I ended up using -R

hiredman17:11:09

similar questions have come up a few times, it makes me wonder if there is a tutorial or documentation somewhere that is using -R in examples where it should be using -A

fmjrey17:11:57

> You can add this dependency to your classpath by adding the :bench alias to modify the dependency resolution: clj -R:bench.

fmjrey17:11:17

Not even sure I understand the difference between -A and -R from the cli doc

richiardiandrea17:11:39

question about CI and .m2 - is there anything I have to do to set Clojure CLI on a machine for being able to cache artifacts in .m2?

richiardiandrea17:11:11

this machine does not seem to have Maven, do I need it? or .m2/settings.xml

hiredman17:11:31

if you are ci'ing inside some kind of container you might want to set things up so ~/.m2 is stored in a way that persists across different runs

richiardiandrea18:11:30

is .m2 created for me?

hiredman18:11:46

tools.deps will store git deps in ~/.gitlibs too

richiardiandrea18:11:08

ok thanks, my CI executes things in a weird way I think...every call to clojure resets .m2 so it downloads everything again, investigating...

hiredman18:11:00

yeah, you are likely building in some kind of container environment with nothing persisted between builds

richiardiandrea18:11:03

I am on Azure Pipeline..

hiredman18:11:01

in theory that should be fine, m2 is a cache, so if the cache is missing it will just rebuild it, but it is much better to persist m2

hiredman18:11:14

you actually might be running in to another caching issue too

richiardiandrea18:11:38

yeah I see it is redownloading the whole thing

hiredman18:11:22

the clj tool fetches deps and builds the classpath once and sort of caches that, if the deps it fetches go missing, but the cache file it generates is still there, it will blow up

richiardiandrea18:11:55

makes sense yeah

richiardiandrea18:11:59

thank you so much

richiardiandrea19:11:18

which command creates .m2? I know first execution does, but I would like to see it there before running my actual other tasks

richiardiandrea19:11:32

can I just do clojure -Sdescribe?

richiardiandrea19:11:41

actually let me try locally

richiardiandrea19:11:56

$ mv .m2 .m2-backup
$ clojure -Sdescribe
Downloading: org/clojure/clojure/1.10.0-alpha6/clojure-1.10.0-alpha6.pom from 
Downloading: org/clojure/spec.alpha/0.2.168/spec.alpha-0.2.168.pom from 
Downloading: org/clojure/pom.contrib/0.2.2/pom.contrib-0.2.2.pom from 
Downloading: org/clojure/core.specs.alpha/0.2.36/core.specs.alpha-0.2.36.pom from 
Downloading: org/clojure/clojure/1.10.0-alpha6/clojure-1.10.0-alpha6.jar from 
Downloading: org/clojure/spec.alpha/0.2.168/spec.alpha-0.2.168.jar from 
Downloading: org/clojure/core.specs.alpha/0.2.36/core.specs.alpha-0.2.36.jar from 
{:version "1.9.0.397"
 :config-files ["/home/arichiardi/.local/lib/clojure/deps.edn" "/home/arichiardi/.clojure/deps.edn" ]
 :install-dir "/home/arichiardi/.local/lib/clojure"
 :config-dir "/home/arichiardi/.clojure"
 :cache-dir "/home/arichiardi/.clojure/.cpcache"
 :force false
 :repro false
 :resolve-aliases ""
 :classpath-aliases ""
 :jvm-aliases ""
 :main-aliases ""
 :all-aliases ""}
$ ll ~/.m2
total 24
drwxrwxr-x   3 arichiardi arichiardi  4096 Nov  1 12:45 ./
drwxr-xr-x 120 arichiardi arichiardi 16384 Nov  1 12:45 ../
drwxrwxr-x   3 arichiardi arichiardi  4096 Nov  1 12:45 repository/

richiardiandrea19:11:29

it is downloading alpha6 by default

Alex Miller (Clojure team)20:11:14

No, it’s not - that’s an artifact of your deps.edn files

Alex Miller (Clojure team)20:11:47

By default, clj will use 1.9.0 based on the ~/.clojure/deps.edn

richiardiandrea20:11:10

I should have use -Srepo maybe?

richiardiandrea20:11:53

another question I have is if I can have aliases in parent dir and consume in children dir, in a monorepo setup for instance

richiardiandrea21:11:26

I tried with CLJ_CONFIG to the root but I don't see it working...

richiardiandrea21:11:21

oh now I see it working cool