Fork me on GitHub
#leiningen
<
2019-12-06
>
antono14:12:06

Hey, I am having a problem with lein When I run lein test it works normally, but when I run lein with-profile ci-tests, I get the error

Syntax error (IllegalAccessError) compiling at (clojure/tools/reader/edn.clj:1:1).
reader-error does not exist
This is the profile config:
:test {:resource-paths ["test/resources"]
                    :dependencies [[clj-http "3.10.0"]]} 
             :ci-tests {:test-paths ["ci-tests/resources"]
                    :dependencies [[clj-http "3.10.0"]]}

mikerod14:12:20

@aoellerer do you have any other profiles?

antono14:12:37

:dev {:resource-paths ["dev/resources"]
                    :source-paths ["dev"]
                    :dependencies [[org.clojure/tools.namespace "0.3.1"]
                                   [clj-http "3.10.0"]]}}

mikerod14:12:56

Ok. So try lein with-profile +ci-tests ie added a +

mikerod14:12:19

Also I’m pretty sure the :test profile is always going to be active during the test task. So if you need stuff to not be included during ci-tests then they should go to a non-special profile.

antono14:12:40

What do you mean? That I can take the clj-http dependency out of the dependecies?

antono14:12:30

Ok, I now get a similar error when running lein uberjar

antono15:12:20

It seems as if you have to include [org.clojure/tools.reader "1.3.2"] into the dependencies

mikerod15:12:10

@aoellerer you are transitively getting that dependency (`org.clojure/tools.reader`) from org.clojure/tools.namespace most likely

mikerod15:12:30

if you have an explicit dependency on it, it’s correct for you to declare it directly instead of rely on org.clojure/tools.namespace to bring it for you

mikerod15:12:03

lein ubejar will not include default lein profiles - intentionally it leaves out all profiles not specified except the “special” profile name uberjar

mikerod15:12:24

this is because the default profiles have things that shouldn’t be in your “production deployed artifacts”

mikerod15:12:58

and when you use with-profile you take explicit control of what profiles are added - so again, the default lein profiles do not get added

mikerod15:12:42

if you use with-profile +my-profile that means to include my-profile plus any other default profiles already active

mikerod15:12:07

which worked in your ci-tests case, since presumably you were running the test task

mikerod15:12:01

lein uberjar and lein jar (which also affects lein install )are a bit more aggressive though - they will remove default profiles and you have to instead use :leaky metadata - but won’t get into that - not typically needed

antono15:12:43

Thank you!

👍 4
mikerod16:12:59

no problem, hopefully it starts to make sense for you w/this