Fork me on GitHub
#figwheel
<
2018-08-02
>
gas10:08:59

iM trying to get figwhell main to run with own server however keep getting this error.

gas10:08:01

figwheel-main.edn is valid! Unable to find :ring-handler

gas10:08:44

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?

bhauman13:08:09

@gas the ring-handler needs to be on the classpath

gas19:08:19

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

gas19:08:13

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}

bhauman19:08:49

@gas I'd need more details

bhauman19:08:01

what is your classpath?

bhauman19:08:16

is src/clj on your classpath?

gas19:08:23

deps.edn :paths [“src/cljs” “src/clj” “target” “resources”]

bhauman19:08:21

well that's odd

gas19:08:02

tryed with .clj in same directory as .cljs as well - yeah I have been basically just doing tutorial then moved onto your documentation

bhauman19:08:56

and the error is not found?

gas19:08:00

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

bhauman19:08:20

can I see the contents of your server file?

bhauman19:08:36

because this can happen if there is an error in the file

bhauman19:08:25

that is probably what is happening

gas19:08:36

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\“&gt; </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)))

bhauman19:08:04

so here is what I would do

gas19:08:21

but pretty sure it didnt work on your one but can retry with that

bhauman19:08:48

start a REPL with clj

bhauman19:08:42

and then (load "src/clj/config_manager/server.clj")

bhauman19:08:03

I think you just have a problem in your file

bhauman19:08:51

I'm going to record an issue that there needs to be feedback if there is an error when loading the file

bhauman19:08:28

and I'm going to check that it works myself

gas19:08:31

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!

bhauman19:08:45

rm -rf target/public

bhauman19:08:52

btw there is a #figwheel-main channel

bhauman19:08:02

yeah there is a bug in my server as well

bhauman19:08:06

in the docs

gas19:08:19

oh didnt know that looks like I have prob with some other file as keep getting same error

bhauman19:08:17

oh lots of errors in that example

gas19:08:01

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

bhauman19:08:34

@gas I'm not understanding what you are saying

bhauman19:08:07

did you try my suggestion above? to load the file?

gas19:08:31

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.

bhauman19:08:25

OK now I'm having trouble loading the ring-handler

bhauman19:08:44

So I guess this is a bug

bhauman20:08:25

yeah somethings not working

bhauman20:08:07

I'm going to go eat and then come back to this

gas20:08:27

OK - good Ive just woke up so will have breakfast 🙂 - and Ill go on main

gas20:08:03

ClojureScript 1.10.339
cljs.user=> (load "src/clj/config_manager/server.clj")
Compile Exception:

bhauman20:08:36

actually (load "config_manager/server")

gas20:08:38

same error - and now using your server.clj