ring

cschep 2021-03-25T04:36:33.053300Z

sorry if this isn’t the right place, but I’ve got some compojure routes like so

(defroutes routes
  (GET "/" [] (index/index))
  (route/resources "/")
  (route/not-found "oh no"))

cschep 2021-03-25T04:36:49.053700Z

i’ve got some static assets in resources/public

cschep 2021-03-25T04:36:56.054Z

and they are 404'ing

cschep 2021-03-25T04:38:09.054400Z

is it laid out somewhere what directory to use?

seancorfield 2021-03-25T04:55:00.055200Z

Hmm, I thought the default was public on the classpath. Ah, how are you starting/running your app? Leiningen or Clojure CLI?

seancorfield 2021-03-25T04:56:05.056200Z

I can't remember whether lein puts resources on the classpath by default but deps.edn certainly doesn't -- you need to set :paths ["src" "resources"] in your deps.edn.

seancorfield 2021-03-25T04:56:30.056400Z

^ @cschep

cschep 2021-03-25T04:56:49.056600Z

ahhhh

cschep 2021-03-25T04:57:13.057100Z

clj -M -m schepball.main

cschep 2021-03-25T04:57:22.057300Z

with a pretty bare deps.edn

cschep 2021-03-25T04:57:27.057600Z

i was wondering how the tool knew where to look

cschep 2021-03-25T04:57:40.058Z

maybe “resources” was a magic jvm directory or something

cschep 2021-03-25T04:57:57.058300Z

is src in deps.edn by default?

cschep 2021-03-25T04:58:05.058600Z

{:deps
 {org.jsoup/jsoup {:mvn/version "1.13.1"}
  dk.ative/docjure {:mvn/version "1.14.0"}
  compojure/compojure {:mvn/version "1.6.2"}
  ring/ring {:mvn/version "1.9.2"}}}

cschep 2021-03-25T04:58:11.058800Z

this is my entire deps.edn

cschep 2021-03-25T04:58:39.059Z

but i have code in src

cschep 2021-03-25T05:01:54.059200Z

that fixed it thank you!!

seancorfield 2021-03-25T05:54:04.060500Z

Yes, "src" is the default value for :paths. If you need additional directories, you need to specific (all of) them in your project deps.edn, so :paths ["src" "resources"] would need to be added.

seancorfield 2021-03-25T05:56:17.061600Z

You can see it reflected in the classpath here:

seanc@DESKTOP-30ICA76:~/clojure$ clojure -Spath
# just src on the path (plus Clojure's libs):
src:/home/seanc/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/home/seanc/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/home/seanc/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar
seanc@DESKTOP-30ICA76:~/clojure$ clojure -Sdeps '{:paths ["src" "resources"]}' -Spath
# now we have src and resources on the path:
src:resources:/home/seanc/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/home/seanc/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/home/seanc/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar