Fork me on GitHub

Has anyone gotten clojure w/deps.edn running on heroku recently? I tried the blank project.clj trick and the build script runs, but for whatever reason doesn't see my uberjar.clj file


uberjar.clj file? Do I assume you mean the built project-name.jar uberjar file? I used to use the following customised Leiningen build for Clojure CLI projects previously - but since then have cancelled all my Heroku accounts (Note: I used to work for Heroku 2012-2017) (this content will be deprecated soon) Rather than the build from source approach on Heroku, a docker image could be created locally and deployed on Heroku. Or if possible to change your deployment service, consider (there are other services too) (Note: I dont work for any cloud service company)


i mean i have a build alias which just runs this file


(ns uberjar
  (:require [ :as b]
            [ :as bb]
            [ :as sh]))

(defn -main
  "Builds an uberjar"
  [& _]
  (let [tailwind-run-result (sh/sh "bb" "tailwind")]
    (when (not= 0 (:exit tailwind-run-result))
      (binding [*out* *err*]
        (println (:err tailwind-run-result)))))

  (let [class-dir "target/classes"
        uber-file "target/standalone.jar"
        opts      {:class-dir     class-dir
                   :compile-opts  {:direct-linking false}
                   :main          'proj.main
                   :uber-file     uber-file
                   :exclude       ["license(.)*"]
                   :src-dirs      ["src"]
                   :resource-dirs ["resources" "prod"]}]
    (b/delete {:path class-dir})
    (bb/uber opts)
    (println "Uberjar is built.")



Was a bin/build script added to the project with a command that would run the relevant code from the uberjar namespace to create the uberjar on Heroku? This would be the same command run locally to create the uberjar file?


I'm running a deps.edn project on Heroku, but from sources, and with a custom buildpack. :) So probably not useful to you at all.


yep - bin/build just does clojure -M:build


and it is being detected and run


getting new failure now


remote:        java.lang.NullPointerException
remote:        	at$make_session.invokeStatic(maven.clj:221)
remote:        	at$make_session.invoke(maven.clj:216)
remote:        	at$read_descriptor$fn__1047.invoke(maven.clj:111)
remote:        	at$retrieve$reify__356.apply(session.clj:28)
remote:        	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(
remote:        	at$retrieve.invokeStatic(session.clj:25)
remote:        	at$retrieve.invoke(session.clj:18)
remote:        	at$retrieve_local.invokeStatic(session.clj:35)
remote:        	at$retrieve_local.invoke(session.clj:30)
remote:        	at$read_descriptor.invokeStatic(maven.clj:111)
remote:        	at$read_descriptor.invoke(maven.clj:106)
remote:        	at$eval1074$fn__1075.invoke(maven.clj:146)
remote:        	at clojure.lang.MultiFn.invoke(
remote:        	at$expand_deps$children_task__662$fn__664$fn__665.invoke(alpha.clj:405)
remote:        	at$submit_task$task__298.invoke(concurrent.clj:35)
remote:        	at
remote:        	at
remote:        	at java.util.concurrent.ThreadPoolExecutor.runWorker(
remote:        	at java.util.concurrent.ThreadPoolExecutor$
remote:        	at
remote:        Execution error (NullPointerException) at (maven.clj:221).
remote:        null
remote:        Full report at:
remote:        /tmp/clojure-6079687224478408742.edn
remote:  !     Failed to build.
remote:  !     Push rejected, failed to compile Clojure app.
remote:  !     Push failed
remote:  !


Oh, another tidbit - I ended up being fed up with fiddling with building on Heroku whenever my build process would require something new. Ended up switching to Docker images (although with Podman instead of Docker), and definitely won't look back at pure source-based deployment. WRT that error - there should be a way to print that report as well. I think you can add to the clojure command to do that.

Zmicier Misiuk22:03:26

I was able to run deps.edn project with this buikdpack and bin/build . It's important to set right versions of Clojure and jdk for app by and CLOJURE_CLI_VERSION env variable.


upgrading the jdk version from 8 mysteriously solved everything. not gonna think on it too hard

catjam 2
Zmicier Misiuk16:03:37

What version of jdk you use now?


i bumped to 19 from the default of 8