Fork me on GitHub
#leiningen
<
2021-03-19
>
uiltjesrups08:03:22

Hi, What's the reason lein deps does not retrieve the ring-codec jar when I do not explicitly mention ring-codec as a dependency in project.clj? Because of this lein run has to retrieve the jar first which deteriorates startup time. Is including ring-codec in project.clj the best way to prevent this?

$ lein deps # ring-codec not included as dependency in project.clj
Retrieving ring/ring-codec/1.1.2/ring-codec-1.1.2.pom from clojars

$ rm -rf ~/.m2/repository/ring/ring-codec/1.1.2

$ lein deps # ring-coded included as dependency in project.clj
Retrieving ring/ring-codec/1.1.2/ring-codec-1.1.2.pom from clojars
Retrieving ring/ring-codec/1.1.2/ring-codec-1.1.2.jar from clojars

mikerod16:03:36

@uiltjesrups you need to have all deps pulled your project uses. these are not limited to only those you directly/explicitly specify in your project.clj. you also have to pull in all of your dependencies’ depencencies, and transitively all of theirs

mikerod16:03:49

so deps form a tree of deps, and those deps’ deps, and so on

mikerod16:03:13

lein shouldn’t need to pull this every time under standard setup since it caches it to your local repository - on the machine lein is ran

mikerod16:03:46

defaulting to ~/.m2/respository

👀 3
noisesmith16:03:29

@uiltjesrups that situation makes me think your run task uses some plugin adding deps that the default project doesn't include

noisesmith16:03:31

I never call "lein deps", it's a subtask that nearly every other task calls for you

uiltjesrups16:03:51

@noisesmith Thanks, it might be the lein duct plugin, I will try it out. I use lein deps in my dockerfile, so all dependencies are pulled during building the image.

noisesmith16:03:01

if you build a fat jar instead of using lein inside the docker image, you don't have to worry about any of that

noisesmith16:03:21

(also you get better startup time and a simpler container setup)

noisesmith16:03:27

also this allows switching painlessly to clj (or whatever else gets invented), as all you need inside the container for the clojure code to work is a jvm and a jar

uiltjesrups16:03:34

I started with that but ran into problems (long story) and lein run was a quick solution, I thought... You convinced me to do it the right way anyway. Thanks!

noisesmith16:03:34

note that using an uberjar does not require aot - you can use clojure.main

Endre Bakken Stovner18:03:23

When trying to start lein repl I get the error message Caused by: java.lang.RuntimeException: Unable to resolve symbol: create in this context. Does anyone know what I might be doing wrong?