Fork me on GitHub
#figwheel-main
<
2018-09-10
>
roper10:09:21

Hi, is there please a version of https://github.com/bhauman/figwheel-template using figwheel-main?

ingesol10:09:32

Hi! Just created a figwheel-main project by doing lein new figwheel-main client2, but getting exception when running lein fig:build aftterwards. Running on windows. Exception is Unable to dynamicly load figwheel.server.jetty-websocket/run-server {:not-loaded figwheel.server.jetty-websocket/run-server}

ingesol10:09:50

Cloning the flappy bird repo works, investigating what the difference is

ingesol10:09:20

So, basically you have to put your cljs-dependencies in deps.edn, and definitely not put them in project.clj, it seems?

ingesol11:09:22

On windows, if I put the same dependency in project.clj and in deps.edn, I get this error: `Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect at java.io.WinNTFileSystem.canonicalize0(Native Method) at java.io.WinNTFileSystem.canonicalize(Unknown Source)`

bhauman13:09:55

@U21QNFC5C I’d like to track this down

bhauman13:09:27

deps.edn doesn’t have any effect on windows right, because the Clojure tools aren’t available there yet correct?

ingesol13:09:18

well, I had to put my deps in deps.edn in order to get things going

bhauman13:09:33

but you are using lein?

ingesol13:09:52

I pretty much spent the last 4 hours trying to get started on windows, there were several things stopping me.

bhauman13:09:10

deps.edn has no effect on Windows at all

bhauman13:09:33

unless you are using the tools-deps plugin?

ingesol13:09:36

Current finding: the template comes with 0.1.5, which does not work with less-than-four-of-these. But with 0.1.9, it works

ingesol13:09:11

so this will be kinda badly structured as a feedback right now, I could make a list and post it again in a new thread

ingesol13:09:23

will check out the deps.edn thing now that the other stuff is working for me

ingesol13:09:39

I believe you when you say that it does not affect windows 🙂

bhauman13:09:17

when you use the template it makes a project.clj file that depends on figwheel-main 0.1.5?

ingesol13:09:18

I believe so yes

bhauman13:09:55

hmm well it shouldn’t have, that sounds like a stale jar or something

bhauman13:09:17

anyway I’d love to hear what you have found

ingesol13:09:53

no, not true. Template gives me 0.1.9

ingesol13:09:13

I've been thoroughly confused during the day, so don't listen to me until I've summarized here 🙂

ingesol10:09:33

@perglr And accidentally I answered your question 🙂

roper10:09:07

Nice synchronicity 🙂. lein new figwheel-main works at my Linux machine, but I miss the server-side part there -- seems just like a client-side project...

ingesol10:09:39

@perglr I think that's by design. You could check this out https://github.com/pesterhazy/cljs-spa-example

ingesol10:09:21

after a closer look, that one might not be too server-centric either 🙂

roper10:09:31

A nice one! I like having the separation of concerns in the template, however I would love e.g. a switch --server, which would generate the server-side code, like the old figwheel-template did... Or what is the best practice now, @bhauman?

roper10:09:26

Hmm, I am now looking at the old template and it does not have the server-side, as well. Sorry for confusion, this must have been different template...

kwladyka14:09:41

clj -A:new figwheel-main form-validator-demo --reagent - what is wrong with this command?

Exception in thread "main" clojure.lang.ExceptionInfo: Project names must be valid qualified or multi-segment Clojure symbols. {:project-name "form-validator-demo"}
Not sure if it is figwheel template issue or clj -A:new, it is my first project with clj

pesterhazy14:09:42

probably the dashes?

bhauman14:09:44

@kwladyka the clj new command annoyingly requires hello.core

bhauman14:09:00

you have to supply a namesapce

bhauman14:09:11

and it has to be more than a single segment

pesterhazy14:09:12

ah ignore what I said

kwladyka14:09:21

hmm so what is form-validator-demo? Not namespace?

pesterhazy14:09:29

form-validator.demo

pesterhazy14:09:19

Clojure discourages (but doesn't forbid) single-segment namespace names like "hello". Apparently clj-new enforces that convention

kwladyka14:09:26

hmm so normally with lein it is form-validator-demo.core?

pesterhazy14:09:46

yup that should work

bhauman14:09:11

you can pass form-validator-demo to lein and it will work and generate form-validator-demo.core

bhauman14:09:44

so yeah with clj new you have to pass form-validator-demo.core

kwladyka14:09:45

What is the point of this change? To not use core as default one?

bhauman14:09:19

but I’m not the one who advocated it

bhauman14:09:01

and since most of the time when I use a template, I’m using it on a temp project to validate behavior, I think its a bit overkill

kwladyka14:09:05

oh and it even create folder orm-validator-demo.core instead of orm-validator-demo which I would expect

kwladyka14:09:21

why not use core as default ns?

bhauman14:09:34

but you can use lein new figwheel-main form-validator-demo +deps and it will do what you want

bhauman14:09:00

like I said it wasn’t my decision

kwladyka14:09:21

clj as first tool in clojure world makes me confuse

bhauman14:09:22

and I dissagree with it

kwladyka14:09:21

but perhaps because of luck of answers "why they did some choices"

bhauman14:09:59

well I think clj is a very good tool, and you have to remember that clj-new isn’t part of clj

pesterhazy14:09:13

you could file an issue with clj new

bhauman14:09:31

that won’t get you far

bhauman14:09:47

this has already been argued

pesterhazy14:09:42

Funny, Sean has previously been very responsive with suggestions

bhauman14:09:17

well, I shouldn’t prevent someone from making the point again

pesterhazy14:09:40

might to be good to have the argument on record

kwladyka14:09:43

I would be enough satisfy to read rationals 🙂

bhauman14:09:54

to me the strongest argument is that one way that templates are used is for temporary throw away projects

bhauman14:09:40

and in most clojurescript projects you are creating an application and not a library for others to consume

pesterhazy14:09:42

if would be easy to just print a warning and use XXX.core if the string contains no dot

kwladyka14:09:23

add it to readme with explanation will be enough 😉

bhauman14:09:48

yeah that won’t fly either because the feature was put in place to prevent the abundance of .core files

bhauman14:09:16

but a different message would be very helpful

pesterhazy14:09:19

@kwladyka I think filing an issue - if only for posterity - would help: https://github.com/seancorfield/clj-new/issues

ingesol14:09:48

@bhauman So a couple of issues:

ingesol14:09:51

First of all, the flappy sample app points to figwheel-main 0.1.5, which seems to have issues on windows

ingesol14:09:51

After fixing that, I came pretty far. My current issue is the same as the one I started with: Unable to dynamicly load figwheel.server.jetty-websocket/run-server {:not-loaded figwheel.server.jetty-websocket/run-server}

ingesol14:09:10

My full project.clj:

ingesol14:09:15

`(defproject cse-client "1.0.0" :min-lein-version "2.0.0" :dependencies [[kee-frame "0.2.7"] [org.clojure/clojurescript "1.10.312"] [org.clojure/clojure "1.9.0"] [expound "0.7.1"]] :resource-paths ["resources" "target"] :clean-targets ^{:protect false} ["target/public"] :profiles {:dev {:dependencies [[com.bhauman/figwheel-main "0.1.9"] [com.bhauman/rebel-readline-cljs "0.1.4"] [binaryage/devtools "0.9.10"] [day8.re-frame/re-frame-10x "0.3.3-react16"]]}} :aliases {"fig" ["trampoline" "run" "-m" "figwheel.main"] "fig:build" ["trampoline" "run" "-m" "figwheel.main" "-b" "dev" "-r"]}) `

Andreas Liljeqvist15:09:42

Unable to dynamicly load is related to conflicting deps for jetty

Andreas Liljeqvist15:09:04

certain versions of datomic will conflict and require exclusions

ingesol15:09:21

right, I'm not using datomic so must be something else then

ingesol15:09:18

tried removing kee-frame, expound, devtools and re-frame-10x, same result...

Andreas Liljeqvist15:09:20

try to get the whole deps tree printed and check if anything else than figwheel needs jetty-websocket/*

Andreas Liljeqvist15:09:40

I can't remember how to check that in lein anymore

ingesol15:09:10

I did a lein deps :tree now, there are 2 org.eclipse.jetty.websocket deps on root, nothing down the tree

ingesol15:09:48

Which makes sense, given that I ran it with zero deps except figwheel, rebel, clojure and cljs

ingesol15:09:29

And I do realize that there's a good chance I'm doing something wrong 🙂 Using leiningen 2.8.1, and a pretty stripped down project

bhauman15:09:43

@U21QNFC5C this does look like it may be some kind of bug on windows

bhauman15:09:53

I don’t think its jetty related

ingesol15:09:34

The thing i found with 0.1.5 was that one-two-three-four works as project folder, one-to-three does not. Super weird, and resulted in that dynamic loading error. It went away when upgrading to 0.1.9, but I'll re-check it soon

bhauman16:09:19

so it’s working?

bhauman16:09:47

with 0.1.9? if it works with 0.1.9 that’s all that matters to me

ingesol16:09:00

no, but I wanted to test if it will work again if I change the project folder/name from client to client-with-long-enough-name

bhauman16:09:41

I have a way for you you to debug the problem from lein repl

bhauman16:09:39

(require 'figwheel.server.jetty-websocket)

bhauman16:09:59

and if that works (resolve 'figwheel.server.jetty-websocket/run-server)

bhauman16:09:23

that should return the var

ingesol16:09:40

excellent, I'll try that in a bit. Just now I made a copy of my "client" folder, named it "super-long-name-client", and removed all deps except clj and figwheel, that actually launched

ingesol16:09:42

OK, launched the repl now on the non-working foolder named "client"

ingesol16:09:28

With the same project.clj as above, got the following error on the require CompilerException java.io.FileNotFoundException: Could not locate ring/core/protocols__init.class or ring/core/protocols.clj on classpath., compiling:(ring/util/servlet.clj:1:1)

ingesol16:09:51

ok, added explicit dependency on ring-core "1.7.0", that seems to have made a difference

ingesol16:09:40

still no go launching fig:build, but made a difference in the repl

ingesol16:09:05

ok, 100% sure now that explicitly adding ring-core as a dependency made your REPL-statements work

ingesol16:09:52

The project with a "really-long-folder-name" now starts nicely with added ring-core 1.7.0 dep. The one with "shortname" does not.

bhauman16:09:56

that is weird

bhauman16:09:34

Ring core 1.7.0 was released 4 hours ago 🙂

ingesol06:09:37

Only the latest and greatest products are good enough for me and my windows computer 🙂

ingesol08:09:11

ok, got some distinct findings on the folder issue. Tried with the exact same project folder content, made copies with only folder name changed:

ingesol08:09:28

Folder name p01234567890123456789: clojure.lang.ExceptionInfo: Figwheel: Unable to dynamicly load figwheel.server.jetty-websocket/run-server {:not-loaded figwheel.server.jetty-websocket/run-server}

ingesol08:09:35

Folder name p012345678901234567890 (one character longer) Works perfectly, launches figwheel with standard html page, reload works

ingesol08:09:46

Folder name p0123456789012345678901234567890123456789 java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64, compiling:(ring/util/codec.clj:1:1)

ingesol08:09:30

Base folder of the experiments so far is C:\dev\go\src\backup-cse

ingesol08:09:42

Trying the folder C:\p0123456789012345678901234567890123456789 (same as last attempt, only on root) clojure.lang.ExceptionInfo: Figwheel: Unable to dynamicly load figwheel.server.jetty-websocket/run-server {:not-loaded figwheel.server.jetty-websocket/run-server}

ingesol08:09:21

I'm on windows 10 with a very minimal project. Would you like an issue on this, @bhauman?

ingesol11:09:17

I'm beginning to think this is an issue with the total length of the classpath string on windows. The issue came back now when adding devcards as a dependency. Moved folder some levels closer to root, then it works

ingesol11:09:43

Shortened name of project folder, then the problem is back

ingesol10:09:49

Made an issue https://github.com/bhauman/figwheel-main/issues/74 . Sorry for nagging about this, will fall back to regular figwheel now as I've not been able to get a stable build running.

bhauman13:09:41

@U21QNFC5C this is a windows command line path length problem https://github.com/technomancy/leiningen/issues/2452

bhauman13:09:54

so it has nothing to do with figwheel

ingesol19:09:44

Ok, I should have known.. Sorry about the mess, I'll close the issue

dimovich15:09:52

Hello. I'm using the Sente library, and it doesn't have support for Jetty. How can I bypass the figwheel's default server, and use my own?

dimovich15:09:48

when using another server, figwheel can't connect to the browser

dimovich15:09:04

2018-09-10 18:25:19.151:WARN:oejs.HttpChannel:qtp1463775359-31: /figwheel-connect?fwprocess=4e3b7c&fwbuild=dev&fwsid=3e71f2ac-12b6-49ce-8cec-39110655da2a
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getServletContext()Ljavax/servlet/ServletContext;

bhauman15:09:10

@dimovich what are you doing specifically

dimovich15:09:41

:pre-build-hooks [project.core/init]

dimovich15:09:59

where I'm starting a server

bhauman15:09:06

that’s going to run on every file change

bhauman15:09:17

so that’s not a good idea

bhauman15:09:42

unless its designed to run over and over again

dimovich15:09:49

no, it's not

bhauman15:09:09

also when you start your server

bhauman15:09:25

are you changing anything else?

bhauman15:09:18

the best way to run your own server is to start it with a -init or and -eval option with clj

bhauman15:09:50

ie put a start-server function in your user.clj file and add -e “(user/start-server)”

bhauman15:09:29

also you need to add make your server serve the compiled clojurescript assets

dimovich15:09:07

yeah, it does that... will try the -eval now

dimovich15:09:13

does figwheel have to start its own server?

bhauman15:09:22

yes, it does

dimovich15:09:42

how does one mix the :main-opts [...] and the -e from the command line?

bhauman15:09:29

you either have to add it to the :main-opts or do it all on the command line

bhauman15:09:39

in this case because the -e has to come first

dimovich15:09:53

ok, thanks!

dimovich15:09:35

btw, from the documentation it isn't clear that the :pre-build-hooks are run every time

bhauman15:09:26

I just corrected the docs

dimovich15:09:08

oh, nice 🙂

dimovich16:09:14

still getting the above error...

bhauman16:09:45

are both servers launching on the same port?

bhauman16:09:52

or different ports?

dimovich16:09:16

different ports, and I'm opening the page on my server's port

bhauman16:09:38

did you change any other figwheel config?

bhauman16:09:50

like :open-url?

dimovich16:09:32

{:css-dirs ["resources/public/css"]
 :watch-dirs ["src/cljs" "src/cljc"]
 :open-url false}

bhauman16:09:32

because figwheel will provide the correct url to connect to by default

bhauman16:09:44

hmmmmm yeah try getting rid of :open-url

bhauman16:09:52

in your config

bhauman16:09:52

whats important here is the url that figwheel is trying to connect to, and you can see that in the console

bhauman16:09:34

yeah its not open url

bhauman16:09:01

the url its trying to connect to should be localhost:9500 based on defaults

dimovich16:09:41

but then I won't get to my server handler...?

bhauman16:09:00

no open the page as usual

bhauman16:09:21

but in the dev console you wil see where figwheel is trying to connect

bhauman16:09:33

and that should be localhost:9500

dimovich16:09:34

yeah, it is

dimovich16:09:02

websocket.js:283 WebSocket connection to '' failed: Error during WebSocket handshake: Unexpected response code: 500

bhauman16:09:27

Then what I think is happening is that there is a simple jetty conflict in your dependencies

dimovich16:09:22

I'm using javax.servlet/servlet-api {:mvn/version "2.5"}

dimovich16:09:45

maybe there is a conflict in that

bhauman16:09:52

yeah that looks right

bhauman16:09:42

javax.servlet/javax.servlet-api 3.1.0

bhauman16:09:57

looks like you need 3.1.0

bhauman16:09:12

moving to the dominant webserver platform is having drawbacks

dimovich16:09:47

@bhauman thanks! trying now

dimovich16:09:15

[Figwheel REPL] Session Name: Dirk 🙂

dimovich16:09:33

yay, it works! @bhauman thanks!

👍 4
tmarble16:09:13

Really excited to try the new testing stuff with figwheel main! I'm starting with the flappy-bird-demo-new and adding a new namespace 'core-test.cljs' in the context of using lein so I'm wondering... where do I put my :auto-testing config option? should it go in the project map at [:cljsbuild :builds 0 :figwheel] ?

bhauman16:09:56

@tmarble I’d start with the figwheel-main template

bhauman16:09:04

its all setup already

tmarble17:09:05

excellent.. I'll try that!, thx!

bhauman17:09:42

you’re welcome!

tmarble17:09:30

@bhauman really great "Out of the box" experience, as always!

tmarble17:09:40

When I run fig:build I get the (reagent) app up at http://localhost:9500/ And should I be able to see the tests live updating at http://localhost:9500//figwheel-extra-main/auto-testing (b/c that doesn't work)?

tmarble17:09:05

d'oh the // messed it up... fixing the url fixes it!

tmarble17:09:35

OMG with browser notifications! ❤️

tmarble17:09:50

extra credit: I'm really curious about the semantics of ;; specify reload hook with ^;after-load metadata quick scan of clojurescript and figwheel-main didn't highlight where that is used?

tmarble19:09:50

nice, i'll check it out

tmarble19:09:53

progress report: I've got CIDER working with figwheel-main via cider-jack-in-cljs, but not yet cider-jack-in-clj&cljs

tmarble19:09:42

w00t! did M-x cider-connect-sibling-clj from the CLJS REPL and voila!