Fork me on GitHub
#leiningen
<
2018-12-14
>
Daouda04:12:34

hey guys, i am trying to generate the war file of my compojure-api project but it keep generating a jar, help!!!

jumar09:12:18

@UEA9PJ9FE what did you try, what's your project configuration? How do you call it?

Daouda09:12:16

hey @U06BE1L6T, i added main to my project.clj setted a name for uberwar, then ran lein ring uberwar .

jumar09:12:55

It could help if you share your complete project.clj

Daouda04:12:51

can anyone help me please?

ikitommi19:12:35

I have lein check that started to fail on travis as the satisfies? call on on a protocol returns false for no good reason. Works still locally and worked before. When it started failing, the ns checking order changed on travis. Any ideas what and why this happens?

ikitommi19:12:36

order in the successful one:

Compiling namespace muuntaja.core
Compiling namespace muuntaja.format.core ;; the defined protocol
Compiling namespace muuntaja.format.edn
Compiling namespace muuntaja.format.json
Compiling namespace muuntaja.format.transit
Compiling namespace muuntaja.interceptor
Compiling namespace muuntaja.middleware
Compiling namespace muuntaja.parse
Compiling namespace muuntaja.protocols
Compiling namespace muuntaja.util
Compiling namespace muuntaja.format.cheshire
Compiling namespace muuntaja.format.yaml

ikitommi19:12:56

order in the failing one:

Compiling namespace muuntaja.format.msgpack
Compiling namespace muuntaja.interceptor
Compiling namespace muuntaja.middleware
Compiling namespace muuntaja.format.edn
Compiling namespace muuntaja.format.core ;; the defined protocol
Compiling namespace muuntaja.format.json
Compiling namespace muuntaja.format.transit
Compiling namespace muuntaja.parse
Compiling namespace muuntaja.core ;; fails here

ikitommi19:12:07

tried both lein 2.7.1 & 2.8.1

ikitommi19:12:32

test:

lein check

ikitommi19:12:04

travis runs:

./scripts/lein-modules install 
lein do clean, all test, all check

mikerod20:12:43

@U055NJ5CC what is your question? Why satisfies? is sometimes false or why the order is changing sometimess?

mikerod20:12:11

the true/false non-determinism is looking like it should be due to the order changing around

mikerod20:12:23

when a ns compiles the first time it can have the side-effect of extending protocols

mikerod20:12:41

so if that side-effect doesn’t happen before the satifies? call some of the time, those times it’ll be false

mikerod20:12:52

I feel that you have already established that though

hiredman21:12:08

it is likely something to do with the order of loading the protocol and whatever is supposed to satisfy the protocol

ikitommi21:12:57

I think so. I would think lein check should run the checks in order that things get loaded in right order?

ikitommi22:12:20

the tests pass and the lib works, just not the check anymore.

hiredman22:12:56

I forget, but I believe check more or less traverses the namespaces at random (not really random, but not a well defined order) and basically does a require :reload on them

ikitommi22:12:25

feels broken

ikitommi22:12:15

well how can I fix this?

hiredman22:12:33

I am looking at it, but having a little trouble navigating the project because it is new to me and I haven't used whatever module lein plugin this uses

hiredman22:12:05

usually for something like this what I find is 1. a missing require that was covered up some how 2. using the interface instead of the protocol 3. aot weirdness

hiredman22:12:24

actually, you might have another issue as well, check just loads the code (it doesn't invoke tests, etc)

ikitommi22:12:50

ok, thanks for checking it out. Could be the project layout, the :dev requires all the module sources.

hiredman22:12:51

so while I don't know this library or what it does, it is very surprising to me that you are running something at code load time

mikerod22:12:35

I wouldn’t rely on the order namespaces are compiled in by tools like these

mikerod22:12:44

especially when it comes to cross-system

mikerod22:12:49

things may be in sets/maps for one

mikerod22:12:08

the only ordering you know will happen is the dep order of :requires, but still can have different entry points

mikerod22:12:21

I’ve seen things suddenly fail with similar issues as your satisfies? one here

mikerod22:12:34

for reasons of ns loading order changes “non-deterministically”

ikitommi22:12:10

running something at code load time?

ikitommi22:12:58

oh, there is the default instance, which is created at load time.

hiredman22:12:08

actually I bet I know what is going on

hiredman22:12:58

something is capturing the value of the var that contains the protocol Decode

hiredman22:12:42

protocols directly mutate vars

hiredman22:12:11

so if you capture the value of the var, you won't get updates to the protocol (if it is extended to new types, etc)

hiredman22:12:28

so instead of doing (ensure! Decoder) you should do something like (ensure! #'Decoder) and inside the fn returned by ensure! deref the var as needed

hiredman22:12:47

the smoking gun is actually in the travis ci output, the captured value of the protocol var is in the map in the error message under the :protocol key

ikitommi22:12:17

thanks! Will try that when at computer. Is there an explanation about protocols mutating vars somewhere? Would like to understand how they work.

hiredman22:12:43

I don't know of any, but a rule of thumb is, if you are refering to a protocol by a name other than the one created via defprotocol you will likely run into this

hiredman22:12:09

so if you let bind, or apply a function

ikitommi13:12:38

@U0NCTKEV8 coudn’t make it work. will post a minimal failing case into #clojure