Fork me on GitHub
#tools-deps
<
2018-10-15
>
dominicm10:10:57

Unexpected side effect of gitlibs with "optional" namespaces, e.g. for myapp.ns.spec. tools.namespace will try and load the namespace regardless. This is also frustrating for :local/root dependencies, where I actually want to be able to refresh and work on both in parallel, but not necessarily on the specs.

dominicm10:10:47

This is similar to what clojure.core goes through I suppose.

danielneal15:10:22

I'm doing something derp-y here - can anyone halp - what have I missed out?

clj -Sdeps '{cheshire {:mvn/version "5.8.1"}}'
Clojure 1.9.0
user=> (require '[cheshire.core :as json])
FileNotFoundException Could not locate cheshire/core__init.class or cheshire/core.clj on classpath.  clojure.lang.RT.load (RT.java:463)

Alex Miller (Clojure team)15:10:13

clj -Sdeps '{:deps {cheshire {:mvn/version "5.8.1"}}}'

danielneal15:10:21

ah awesome! Thanks

danielneal15:10:37

so excited using the cli for the first time

Alex Miller (Clojure team)15:10:02

I’ve been thinking about adding a warning as this is the nth time someone has asked a question like this

☝️ 4
danielneal15:10:37

haha so yup I can't read but at least it's not just me

danielneal15:10:54

so nice just to get a quick clojure repl to prod this json object - I never can remember how to get jq to do what I want.

seancorfield16:10:45

Yeah, I've been using clj for ages and I still do this, omitting the :deps layer! Probably at least once a day.

mfikes16:10:08

Another warning that could prove useful is if you omit the :mvn/version layer as in

{:deps {cheshire "5.8.1"}}
I do this, say, once per week.

seancorfield16:10:56

You do get an error for that -- but it's a bit obscure.

seancorfield16:10:47

Error building classpath. Coordinate type  not loaded for library cheshire/cheshire in coordinate "5.8.1"

seancorfield16:10:14

(and, yeah, I do that all the time too!)

orestis16:10:35

Sounds like a need for some kind of tool that allows you to write specifications for data?

😂 4
mfikes16:10:52

Yeah, one that is in alpha 🙂

orestis16:10:26

I’ve never typoed the maven thing, but it could be I’m just editing an existing file with plenty of examples.

andy.fingerhut16:10:57

or perhaps a lint-like tool that has custom non-spec code that looks for and warns about data structures that look like they may be mistakes...

andy.fingerhut16:10:13

FYI, a transcript of Alex Miller's "Dependency Heaven" talk is now available here: https://github.com/matthiasn/talk-transcripts/blob/master/Miller_Alex/DependencyHeaven.md

seancorfield16:10:47

We've made a lot of progress in this last week on moving from Boot to clj/`deps.edn` for our monorepo.

seancorfield16:10:58

The issues with relative paths in :local/root has meant we have to have everything "side by side" in one part of the repo.

seancorfield16:10:38

And we found we really needed a baseline deps.edn (in the project) and a per-subproject deps.edn (for each subproject in the repo).

seancorfield16:10:42

So we ended up having a dummy subproject and pointing CLJ_CONFIG at that folder, so we can have all our "pinned" versions in :override-deps in an alias that every command has to use

CLJ_CONFIG=../versions clj -A:defaults:other:aliases

seancorfield16:10:34

We have a small "build" tools subproject with a bunch of -main entry points for various tasks and we bring it in with aliases (in ../versions/deps.edn).

seancorfield16:10:24

We'll probably have a couple of shell scripts to provide some sugar over those invocations but we've got nREPL capabilities, test, build a JAR, run migrations (SQL/data) all up and running with "just" clj and a few aliases. I need to convert two more pieces this week and we'll be close to just removing Boot from our pipeline.

lwhorton17:10:51

hey with the new tools.deps i’m tooling around with a local jar file via the :local/root "/path/to/jar", but changes to the jar don’t seem to be reflected in the repl session. what do i have to do to (reload) or re-require after changing the jar so that the latest code is around in the repl?

Alex Miller (Clojure team)19:10:18

I’m not sure that you can get the default Java classloaders to do this - they don’t pick up modified jar files after startup. So even reloading your Clojure namespace is probably not going to help afaik.

lwhorton19:10:25

that seems to be what’s happening. for now we’re just hard-restarting the whole repl

Alex Miller (Clojure team)20:10:56

Something like a boot pod would give you a fresh classloader and the ability to do this

seancorfield17:10:18

That sounds like a plain ol' REPL workflow issue and you'd need to tell Clojure to reload namespaces from that JAR, regardless of which tool you were using.

👍 4
seancorfield17:10:55

Mind you, if you're rebuilding the JAR locally, why not point :local/root at the source code instead and remove the JAR step?

seancorfield17:10:33

(you'll still need to tell Clojure to reload the code -- after all, the classpath is not changing and Clojure doesn't know to re-read files on the classpath unless you tell it to)

lwhorton17:10:38

> reload namespaces from that JAR is that a good old (require '[foo.bar]) again?

mfikes17:10:33

@lwhorton (require '[foo.bar] :reload)

👍 4
dominicm18:10:43

@seancorfield what layout did you have before?

seancorfield18:10:58

@dominicm We had a top-level deps.edn (equivalent) and our misc. build tooling was in a completely separate folder

build/
  <tooling here>
clojure/
  deps.edn equivalent
  subproject-a/
    deps.edn
  subproject-b/
    deps.edn
  ...

seancorfield18:10:12

Now we have

build/
  <wrapper shell script>
clojure/
  build/
    deps.edn
    build/dev-related Clojure code
  versions/
    deps.edn -- pinned versions and aliases
  subproject-a/
    deps.edn
  subproject-b/
    deps.edn

dominicm18:10:00

@seancorfield not super different then. Interesting solution using CLJ_CONFIG. Hard to get people to set that up, but not a problem in a smaller team though.

seancorfield18:10:09

That's why we have a wrapper shell script 🙂

seancorfield18:10:48

The shell script is basically build task subproject and it maps mostly onto

(cd path/to/<subproject>; CLJ_CONFIG=../versions clojure -A:defaults:<task>)

seancorfield18:10:35

build nrepl datamapper or build test environment or build migrate sql etc

dominicm18:10:28

@seancorfield that doesn't seem very amenable to cursive or ciders jack in? How are you editing?

seancorfield19:10:52

Well, I'm using Atom/ProtoREPL which doesn't support clj in any useful way and my colleague who uses Emacs/CIDER always starts his REPLs by hand and then connects to it via CIDER...

seancorfield19:10:49

Because of the whole CLJ_CONFIG=../versions clojure -A:defaults thing, it's a pain to configure tools to start clj-repls that way anyway.

dominicm19:10:11

Yeah. It is as a result of that 🙂. You could restore that functionality by automating some kind of alias merging across your deps.edn files.

dominicm19:10:31

(This is something I expect I will end up writing, but I'm still fiddling with ways to avoid it)

seancorfield19:10:08

You'd either need to have support for multiple deps.edn files in a clj command or your user deps.edn file would need everything we have in versions/deps.edn tho'... (if you mean to remove CLJ_CONFIG=../versions from the command itself)

seancorfield19:10:21

Either way, not a problem for the sort of usage we have/need.

dominicm19:10:56

I understand. I was looking to you for a silver bullet, as I'm currently getting Edge more & more tools.depsy.

seancorfield19:10:19

There are no silver bullets (tm)!

dominicm19:10:58

I can feel Fred Brooks channeling through you

andy.fingerhut20:10:58

What are your views on bronze bullets? 🙂

arrdem21:10:00

@seancorfield I’d be curious what you think of https://github.com/arrdem/katamari - I just got it to the point of being able to build classpaths, uberjar and self-host last night. It’s designed to solve the sorts of many targets and shared configuration in a single monorepo friction you’re encountering as I hit them too in my first pass at deps for our monorepo.

🍾 4
zane21:10:06

🎶 Na na~ 🎶

seancorfield21:10:06

Will take a look. Thanks @arrdem

arrdem21:10:53

It’s extremely pre-alpha and currently extremely under-documented, but I’m happy to answer questions and will be trying to clean it up as I go.