hoplon/hoplon

Quickstart instructions do not produce a working project

zakwilson opened this issue · 4 comments

$ boot --version
#http://boot-clj.com
#Mon Mar 21 21:23:23 CET 2022
BOOT_VERSION=2.8.3
BOOT_CLOJURE_VERSION=1.10.3
BOOT_CLOJURE_NAME=org.clojure/clojure

$ java --version
openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+3)
OpenJDK 64-Bit Server VM (build 17.0.3+3, mixed mode)
$ boot -d boot/new new -t hoplon -n hoplon-starter-project
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
$ cd hoplon-starter-project/
$ boot develop
[stacktrace.txt](https://github.com/hoplon/hoplon/files/8319054/stacktrace.txt)
java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
      clojure.lang.ExceptionInfo: javax.xml.bind.DatatypeConverter
    file: "cljs/util.cljc"
    line: 1

I googled the error and found #262 which has a comment recommending updating the dependencies, so I did.

$ boot develop
java.lang.IllegalArgumentException: No such task (develop)

The task in build.boot is named dev, not develop.

$ boot dev
Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.10.1
Could not transfer metadata org.clojure:clojure/maven-metadata.xml from/to central (http://repo1.maven.org/maven2): Failed to transfer file: http://repo1.maven.org/maven2/org/clojure/clojure/maven-metadata.xml. Return code is: 501 , ReasonPhrase:HTTPS Required.
Starting reload server on ws://localhost:40607

Starting file watcher (CTRL-C to quit)...

Writing HTML files...
• index.html
Writing adzerk/boot_reload/index.cljs to connect to ws://localhost:40607...
Adding :require adzerk.boot-reload.index to index.html.cljs.edn...
Compiling ClojureScript...
• index.html.js
WARNING: Use of undeclared Var hoplon.app-pages._index_DOT_html/html at line 3 hoplon/app_pages/_index_DOT_html.cljs
WARNING: Use of undeclared Var hoplon.app-pages._index_DOT_html/head at line 4 hoplon/app_pages/_index_DOT_html.cljs
WARNING: Use of undeclared Var hoplon.app-pages._index_DOT_html/link at line 5 hoplon/app_pages/_index_DOT_html.cljs
WARNING: Use of undeclared Var hoplon.app-pages._index_DOT_html/body at line 6 hoplon/app_pages/_index_DOT_html.cljs
WARNING: Use of undeclared Var hoplon.app-pages._index_DOT_html/h1 at line 7 hoplon/app_pages/_index_DOT_html.cljs
Starting Jetty on port 8000...
2022-03-21 21:33:25.052:INFO::clojure-agent-send-off-pool-0: Logging initialized @44561ms
2022-03-21 21:33:25.166:INFO:oejs.Server:clojure-agent-send-off-pool-0: jetty-9.3.1.v20150714
2022-03-21 21:33:25.350:INFO:oejw.StandardDescriptorProcessor:clojure-agent-send-off-pool-0: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2022-03-21 21:33:25.378:INFO:oejsh.ContextHandler:clojure-agent-send-off-pool-0: Started o.e.j.w.WebAppContext@4d226f2b{/,file:///home/zak/.boot/cache/tmp/home/zak/code/hoplon-starter-project/9z55/-kp8cnz/,AVAILABLE}
2022-03-21 21:33:25.384:INFO:oejs.ServerConnector:clojure-agent-send-off-pool-0: Started ServerConnector@6e2f4a24{HTTP/1.1,[http/1.1]}{0.0.0.0:8000}
2022-03-21 21:33:25.384:INFO:oejs.Server:clojure-agent-send-off-pool-0: Started @44894ms
Elapsed time: 32.560 sec

Ok, it's running, but I don't like the look of those warnings. Is it going to work when I load the page? Well, something loads, but it doesn't say "Hello, Hoplon!". Instead, the browser's console says:

Uncaught TypeError: hoplon.app_pages._index_DOT_html.html is undefined
    <anonymous> http://localhost:8000/index.html.out/hoplon/app_pages/_index_DOT_html.js:7

I'm guessing Hoplon 6 automatically requires some stuff that Hoplon 7 doesn't. The example in README.md supports that idea by showing an explicit require. Let's just replace the contents of index.cljs.hl and see if that works.

Writing HTML files...
• index.html
Writing adzerk/boot_reload/index.cljs to connect to ws://localhost:40607...
Adding :require adzerk.boot-reload.index to index.html.cljs.edn...
Compiling ClojureScript...
• index.html.js
Elapsed time: 1.536 sec

Well look at that! No warnings. Unfortunately, the browser renders a blank page instead of a counter app. Here's what's in the console:

Uncaught Error: Bad dependency path or symbol: hoplon.app_pages._index_DOT_html
    visit http://localhost:8000/index.html.out/goog/base.js:2917
    visit http://localhost:8000/index.html.out/goog/base.js:2929
    load_ http://localhost:8000/index.html.out/goog/base.js:2936
    require http://localhost:8000/index.html.out/goog/base.js:905
    <anonymous> http://localhost:8000/:2

There are no useful Google results for that one.

I've just been working on an old project and tried to get my dependencies up to date.

I found I could get my project to build successfully with boot dependencies:

[org.clojure/clojure            "1.11.0"]
[org.clojure/clojurescript      "1.10.339"]
[adzerk/boot-cljs               "2.1.5"]
[adzerk/boot-reload             "0.6.1"]
[hoplon                         "7.2.0"]

and boot properties:

BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.11.0
BOOT_VERSION=2.8.2

The thing that would break my build was updating clojurescript. Version 1.10.339 is the highest I could get to work. Any higher would resulting in all my hoplon html macros not being found like you have described WARNING: Use of undeclared Var...

I did not try requiring hoplon.core and namespacing the macros to see if that works or if I can get clojurescript version any higher but maybe it would be possible.

In terms of fixing the quick start instructions it might be good to get the boot template project dependencies updated to the latest that work. Maybe an issue/pull request should be created there.

Hope this is some help.

Thanks @5slight - with the addition of a boot-jetty dependency that does enable me to run boot dev and get a working development environment.

Bulding for prod with the default (cljs :optimizations :advanced) results in undefined functions with autogenerated names, but it does work without the optimizations.

Broadly, that suggests this project could use an audit for bit rot.

I'm not sure if you are still interested, but I wrote https://github.com/hoplon/project-template that is a template for Hoplon projects using deps-new. I will update the README with it replacing the quickstart instructions if people do not report problems with it soon.

Hoplon has an updated readme with working quick start instructions, I'm closing this, fell free to reopen if you have problems with the new instructions.