Fork me on GitHub
#beginners
<
2015-11-06
>
jeremyraines02:11:36

struggling with this error when trying to create an uberjar with lein uberjar

jeremyraines02:11:43

Uberjar aborting because jar failed: clojure.lang.MapEntry cannot be cast to clojure.lang.IPersistentMap

roberto02:11:01

there is probably an error in your project.clj

jeremyraines02:11:22

will look closer there

roberto02:11:29

yeah, it has happened to me before

jeremyraines02:11:19

probably a stupid question, but do you have to separate your clj and cljs files into different directories and only specify the latter in source-paths for cljsbuild?

roberto03:11:41

this is what I normally do, 1 sec

roberto03:11:16

:profiles {:dev {:plugins       [[lein-cljsbuild "1.1.0"]
                                 [lein-figwheel "0.4.1" :exclusions [org.clojure/clojure
                                                                     org.codehaus.plexus/plexus-utils]]]
                 :dependencies  [[reloaded.repl "0.2.0"]]
                 :env           {:dev? true}
                 :main          zoom-recordings.server.core
                 :open-browser? true
                 :source-paths  ["dev" "src/zoom_recordings/server"]
                 :cljsbuild     {:builds [{:source-paths ["src/zoom_recordings/ui"]
                                           :figwheel true
                                           :compiler {:output-to            "target/classes/public/js/app.js"
                                                      :output-dir           "target/classes/public/js/out"
                                                      :asset-path           "js/out"
                                                      :optimizations        :none
                                                      :recompile-dependents true
                                                      :main                 "zoom-recordings.ui.core"
                                                      :source-map           true}}]}}})

roberto03:11:41

inside my root ns, I have a server and ui namespace

roberto03:11:02

then I configure the source-paths to point the the appropriate ones

roberto03:11:11

I don’t like clj and cljs directories

jeremyraines03:11:13

ok, that seems like what i have

jeremyraines03:11:30

do you have an :uberjar section under :profiles?

roberto03:11:19

it looks similar

roberto03:11:57

:uberjar-common   {:aot          :all
                                :omit-source  true
                                :source-paths ["src"]
                                :main         pasmo-gigi.geo.server
                                :env          {:dev? false}
                                :hooks        [leiningen.cljsbuild]
                                :cljsbuild    {:builds {:app {:source-paths ["src/pasmo_gigi/geo/ui"]
                                                              :jar          true
                                                              :figwheel     false
                                                              :compiler     {:optimizations  :advanced
                                                                             :main           "pasmo-gigi.geo.ui.core"
                                                                             :output-wrapper true
                                                                             :asset-path     "js/out"
                                                                             :output-to      "target/classes/public/js/app.js"
                                                                             :output-dir     "target/classes/public/js/out"

                                                                             :externs        ["resources/public/js/externs.js"]}}}}}
             :uberjar-env-vars {:mongo-uri      (System/getenv "MONGO_URI")
                                :db             (System/getenv "DB")
                                :default-admin  (System/getenv "DEFAULT_ADMIN")
                                :client-id      (System/getenv "CLIENT_ID")
                                :client-secret  (System/getenv "CLIENT_SECRET")
                                :oauth-callback (System/getenv "OAUTH_CALLBACK")
                                :auth-url       (System/getenv "AUTH_URL")
                                :token-url      (System/getenv "TOKEN_URL")
                                :profile-url    (System/getenv "PROFILE_URL")}
             :uberjar          [:uberjar-common :uberjar-env-vars]})

roberto03:11:58

one difference is that in dev I have a dev directory with a repl.clj that I use for restarting the component if I need to during development

roberto03:11:10

but I don’t want that in prod, so it is not in included in the source-paths

roberto03:11:39

and the cljsbuild has some different settings for optimizations

jeremyraines03:11:22

are the cljsbuild builds under uberjar indepedent of the ones specified at the top level? for example, if you had an :app section under :cljsbuild above, does that have anything to do with the one under :uberjar?

roberto03:11:03

I’m not sure I understand

jeremyraines03:11:10

also, when you got the IPersistentMap error, was it a syntax thing, or a configuration issue?

jeremyraines03:11:25

one sec, I’ll post mine with comments in the spots I’m referring to

jeremyraines03:11:34

line 49 and line 70

roberto03:11:27

so at first glance, this caught my eye

roberto03:11:33

:cljsbuild {:builds {:min ;; Does this have anything to do with...
                                            {:jar true
                                             :compiler
                                             {:optimizations :advanced
                                              :pretty-print false}}}}

roberto03:11:42

so, :jar true :compiler

roberto03:11:44

is not valid

roberto03:11:50

is not a valid map

roberto03:11:59

I’m wrong, sorry

jeremyraines03:11:05

I can see from your example that even if it’s not the issue, I should move some dependencies to just be dev dependencies

jeremyraines03:11:58

something also seems to be circular, i see output like this before it crashes

jeremyraines03:11:55

λ lein uberjar                                  
Compiling simoutfit.db
Compiling simoutfit.server
Compiling user
Compiling simoutfit.db
Compiling simoutfit.server
Compiling user
Compiling simoutfit.db
Compiling simoutfit.server
Compiling user
Uberjar aborting because jar failed: clojure.lang.MapEntry cannot be cast to clojure.lang.IPersistentMap

roberto03:11:13

oh, so it is compiling

roberto03:11:27

hmmm, the user.clj probably has an error

roberto03:11:30

it is where it fails

roberto03:11:45

hmmm, well, I’m assuming it is the user.clj

roberto03:11:54

but it is probably something else

roberto03:11:03

why does it compile them 3x?

roberto03:11:10

that looks weird

jeremyraines03:11:39

user.clj is just this though:

jeremyraines03:11:58

(ns user
  (:require [ragtime.jdbc :as jdbc]
            [ragtime.repl :as rtr]))

(defn load-config []
  {:datastore  (jdbc/sql-database (str "jdbc:"
                                       (System/getenv "SIMOUTFIT_DB_PWD")))
   :migrations (jdbc/load-resources "migrations")})

(defn migrate []
  (println "migrating")
  (rtr/migrate (load-config)))

(defn rollback []
  (println "rolling back last migration")
  (rtr/rollback (load-config)))

roberto03:11:42

do you need dev to be compiled in prod?

roberto03:11:53

I’m assuming it has some nrepl stuff

jeremyraines03:11:28

no (to the former)

jeremyraines03:11:02

I was getting some errors related to that before, not at the moment

roberto03:11:45

Hard to tell. I would try compiling without cljsbuild and see if that works. More in an effort to try to isolate the problem

roberto03:11:38

My gut tells me there dis probably some circular dependency in ur clj code. Which is causing the same files to be compiled 3x.

jeremyraines03:11:22

i appreciate your help

jeremyraines06:11:45

this was at least part of the issue, I wonder if that’s documented somewhere

jeremyraines06:11:04

(the linked comments at the end, not that whole issue)

elais20:11:34

I'm newish to emacs and almost completely new to clojure. I was wondering if anyone has configured org-Babel to compile source code in a figwheel repl via inf-clojure

shaun-mahood22:11:59

I've got a function that should be returning a vector [a b c], but is returning ([a b c]) instead. What's the best way to get rid of the outer parens in the function that is calling it?

akiva22:11:08

I’d probably need to see the code but you’re just returning a list the first element of which happens to be a vector.

akiva22:11:02

You could get around it by wrapping the result in a first but that’s treating the symptom and not the cause.

shaun-mahood22:11:33

I'll build a simplified example, it's a little complicated to post right now

shaun-mahood22:11:34

Ok, I just needed to add into [] to get that part to work.

shaun-mahood22:11:51

Thanks for the suggestion, it got me on the right track

akiva23:11:32

Excellent. Glad to hear it.