iM trying to get figwhell main to run with own server however keep getting this error.
figwheel-main.edn is valid! Unable to find :ring-handler
Ive tryed ring-handler in figwheel-main-edn as well as meta in dev.cljs.edn but same result. IS there any special options I need to get figwheel to compile clojure code aka server.clj?
@gas the ring-handler needs to be on the classpath
yeah it is. its name is server.clj under same directory as the .cljs files. hmm mayb my directory has a hyphen in the edn does it need to be _? let me check
nope 😞 src ├── clj │ └── config_manager │ └── server.clj └── cljs └── config_manager ├── config.cljs ├── core.cljs ├── db.cljs ├── events.cljs ├── subs.cljs └── views.cljs figwheel_main {:log-syntax-error-style :concise :ring-handler config-manager.server/handler}
@gas I'd need more details
what is your classpath?
is src/clj on your classpath?
deps.edn :paths [“src/cljs” “src/clj” “target” “resources”]
well that's odd
tryed with .clj in same directory as .cljs as well - yeah I have been basically just doing tutorial then moved onto your documentation
and the error is not found?
any command I should run? clojure -R:dev -A:fig -b dev -r 22:45:29 [Figwheel] Validating figwheel-main.edn [Figwheel] figwheel-main.edn is valid! Unable to find :ring-handler
can I see the contents of your server file?
because this can happen if there is an error in the file
@gas ^
that is probably what is happening
sure been trying heaps of things out (ns config-manager.server (:require [http://clojure.java.io :as io] [bidi.ring :refer (make-handler)] [ring.util.response :as res] [compojure.core :refer :all] [compojure.route :as route] [ring.middleware.reload :refer [wrap-reload]] [ring.middleware.defaults :refer [wrap-defaults site-defaults]])) ;; define index content (def home “<!DOCTYPE html> <html> <head> <meta charset=\“UTF-8\“> <meta name=\“viewport\” content=\“width=device-width, initial-scale=1\“> <link href=\“css/style.css\” rel=\“stylesheet\” type=\“text/css\“> <link rel=\“icon\” href=\“https://clojurescript.org/images/cljs-logo-icon-32.png\“> </head> <body> <div id=\“app\“></div> <script src=\“/cljs-out/dev-main.js\” type=\“text/javascript\“></script> </body> </html>“) (defn handler2 [request] (if (and (= :get (:method request)) (= “/” (:uri request))) {:status 200 :headers {“Content-Type” “text/html”} :body home}} {:status 404 :headers {“Content-Type” “text/plain”} :body “Not Found”})) (defn index-handler [request] (res/response home)) (defn json-handler [request] (res/response (slurp (io/resource “public/dev.json”)) )) (def handler (make-handler [“/” {“index.html” index-handler “devq/” json-handler}])) (defroutes app-routes ;; NOTE: this will deliver all of your assets from the public directory ;; of resources i.e. resources/public (route/resources “/” {:root “public”}) ;; NOTE: this will deliver your index.html (GET “/” [] (-> (res/resource-response “index.html” {:root “public”}) (res/content-type “text/html”))) (GET “/json” [] json-handler) (route/not-found “Not Found”)) ;; NOTE: wrap reload isn’t needed when the clj sources are watched by figwheel ;; but it’s very good to know about (def dev-app (wrap-reload (wrap-defaults #’app-routes site-defaults)))
so here is what I would do
but pretty sure it didnt work on your one but can retry with that
try this
start a REPL with clj
and then (load "src/clj/config_manager/server.clj")
I think you just have a problem in your file
I'm going to record an issue that there needs to be feedback if there is an error when loading the file
and I'm going to check that it works myself
quick? how to you do lein clean with clj? clojure -R:dev -A:fig -r 07:31:28 [Figwheel] Validating figwheel-main.edn [Figwheel] figwheel-main.edn is valid!
rm -rf target/public
btw there is a #figwheel-main channel
yeah there is a bug in my server as well
in the docs
oh didnt know that looks like I have prob with some other file as keep getting same error
oh lots of errors in that example
must be my deps file Im thinking. I dont need to add dependecies devtools, ring as you pull them in for lein? Ill move to figwheel-main
@gas I'm not understanding what you are saying
did you try my suggestion above? to load the file?
cant get past the above error i.e something screwy with my setup just seen that emacs hadnt created directory - so not sure what is going on at present.
OK now I'm having trouble loading the ring-handler
So I guess this is a bug
yeah somethings not working
I'm going to go eat and then come back to this
OK - good Ive just woke up so will have breakfast 🙂 - and Ill go on main
ClojureScript 1.10.339
cljs.user=> (load "src/clj/config_manager/server.clj")
Compile Exception:
actually (load "config_manager/server")
same error - and now using your server.clj