reagent-project / reagent-template

A Leiningen template for projects using Reagent.
MIT License
394 stars 55 forks source link

Can't make project name with underscore #163

Closed fossage closed 5 years ago

fossage commented 5 years ago

Total Clojure noob here so this may be common knowledge, or I may be misinterpreting the issue, but I have found that if I run lein new reagent [any name with underscore] i.e. lein new reagent my_project, any subsequent command will crash.

For example, when I run lein figwheel I get:

Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid ;)
java.lang.IllegalArgumentException: unable to resolve handler var some-project.handler/app for :ring-handler
    at figwheel_sidecar.utils$illegal_argument.invokeStatic(utils.clj:53)
    at figwheel_sidecar.utils$illegal_argument.doInvoke(utils.clj:52)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at figwheel_sidecar.components.figwheel_server$create_initial_state$fn__18794.invoke(figwheel_server.clj:323)
    at figwheel_sidecar.components.figwheel_server$create_initial_state.invokeStatic(figwheel_server.clj:320)
    at figwheel_sidecar.components.figwheel_server$create_initial_state.invoke(figwheel_server.clj:298)
    at figwheel_sidecar.components.figwheel_server$figwheel_server.invokeStatic(figwheel_server.clj:421)
...etc, etc, etc

and when I run lein do clean, run I get:

Exception in thread "main" Syntax error compiling at (some_project/server.clj:1:1).
    at clojure.lang.Compiler.load(Compiler.java:7647)
    at clojure.lang.RT.loadResourceScript(RT.java:381)
    at clojure.lang.RT.loadResourceScript(RT.java:372)
    at clojure.lang.RT.load(RT.java:463)
    at clojure.lang.RT.load(RT.java:428)
    at clojure.core$load$fn__6824.invoke(core.clj:6126)
    at clojure.core$load.invokeStatic(core.clj:6125)
    at clojure.core$load.doInvoke(core.clj:6109)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    ... etc, etc, etc

I'll get crashes like this a various kinds for pretty much any subsequent command I tried. If this is a known thing, it might be worth mentioning in the docs.

Great project btw!

yogthos commented 5 years ago

Hi, thanks for the heads up. The issue was caused by a quirk with Java interop. Clojure uses - for namespace names and doesn't support _ in namespace declarations, but Java doesn't support dashes in package names and they end up being converted to _. I've updated the template to preprocess the project namespace base name to account for that. Let me know if everything looks good on your end.

fossage commented 5 years ago

Just tried it out and it works like a charm!