Fork me on GitHub
#shadow-cljs
<
2021-04-05
>
Vincent Cantin04:04:58

Is the usage of ^:const (e.g. in (def ^:const my-var 3000)) still justified when using shadow-cljs?

thheller07:04:34

^:const is probably the most misunderstood feature in CLJ(S) so I would avoid it. but you can use it if you must.

👍 6
Stewart Foxall15:04:19

Hi total newbie here. Just trying out shadow-cljs, but can’t seem to get past the intial step, am getting a binding error. [2021-04-05 15:44:22.985 - WARNING] :shadow.cljs.devtools.server/socket-repl-ex BindException Can’t assign requested address (Bind failed) http://java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) http://java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387) http://java.net.ServerSocket.bind (ServerSocket.java:375) http://java.net.ServerSocket.<init> (ServerSocket.java:237) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:123) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:115) shadow.cljs.devtools.server/start-system/fn--17877 (server.clj:233) shadow.cljs.devtools.server/start-system (server.clj:232) shadow.cljs.devtools.server/start-system (server.clj:202) shadow.cljs.devtools.server/start! (server.clj:483) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/start! (server.clj:388) BindException: Can’t assign requested address (Bind failed) http://java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) http://java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387) http://java.net.ServerSocket.bind (ServerSocket.java:375) http://java.net.ServerSocket.<init> (ServerSocket.java:237) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:123) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:115) shadow.cljs.devtools.server/start-system (server.clj:248) shadow.cljs.devtools.server/start-system (server.clj:202) shadow.cljs.devtools.server/start! (server.clj:483) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/start! (server.clj:388) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/from-cli (server.clj:615) shadow.cljs.devtools.server/from-cli (server.clj:591) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:665) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:23) shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:20) shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:129) shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132) clojure.core/apply (core.clj:669) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:665) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli/-main (cli.clj:75) shadow.cljs.devtools.cli/-main (cli.clj:67) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:665) clojure.main/main-opt (main.clj:514) clojure.main/main-opt (main.clj:510) clojure.main/main (main.clj:664) clojure.main/main (main.clj:616) clojure.lang.Var.applyTo (Var.java:705) clojure.main.main (main.java:40)

thheller15:04:01

what binding error?

Stewart Foxall15:04:53

Sorry first time using slack and it sent the message before I had finished typing

Stewart Foxall15:04:34

I was using another example, but then switched to using this: https://github.com/shadow-cljs/quickstart-browser I am running on macos 11 if that is relevant

thheller15:04:52

did you block it in your firewall? It needs to open a server socket so you can talk to it via the REPL etc

Stewart Foxall15:04:11

Not as far as I am aware, I have nothing running, checked and can’t see that 8630 port is being used

thheller15:04:49

did you configure anything related to ports in shadow-cljs.edn? or is this with the default setup?

thheller15:04:45

only thing I can think of is your firewall blocking it

Stewart Foxall15:04:27

I did on another example was learning on, but not for quick start. Just followed the commands as is. The file contents is:

;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 []

 :dev-http
 {8020 "public"}

 :builds
 {:app
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"

   :modules
   {:main ; becomes public/js/main.js
    {:init-fn starter.browser/init}}}}}

thheller15:04:58

that looks fine

Stewart Foxall15:04:18

My firewall is off

thheller15:04:30

you can try adding :socket-repl false so it skips trying to start that

thheller15:04:44

but likely it'll then just fail on the next network port it tries to use

Stewart Foxall15:04:51

and thank you for helping

Stewart Foxall15:04:16

To be clear, you mean like this:

;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 []

 :socket-repl false

 :dev-http
 {8020 "public"}

 :builds
 {:app
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"

Stewart Foxall15:04:00

Errors out again

thheller15:04:46

it tries to bind to 0.0.0.0 by default which should be localhost. I do not know why it would fail. nobody else has reported this before.

thheller15:04:15

or rather 127.0.0.1 for the socket-repl. maybe you only have ipv6 configured? no ipv4 at all?

thheller15:04:24

or rather it tries to bind localhost. is that maybe not configured for some reason?

Stewart Foxall15:04:47

Just taking a look now

thheller15:04:58

try ping localhost in the terminal

Stewart Foxall15:04:33

Looks like something to do with my ISP

thheller15:04:05

that is odd. localhost shouldn't leave you machine at all.

thheller15:04:40

I don't actually know where this is configured in macos anymore. maybe still /etc/hosts?

Stewart Foxall15:04:51

This may be the culprit

thheller15:04:05

my macbook has

$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

Stewart Foxall15:04:36

Yes just noticed 127.0.1 was not there, added in and refreshed working now. Thank you!!!!

thheller15:04:51

strange 🙂

Stewart Foxall15:04:17

Very, must have been cleared some point in the past, thanks again…

Max16:04:27

Is there a way to do dev-only dependencies with shadow-cljs, or do you have to integrate with deps or lein?

Azzurite16:04:39

wouldn't dev-only dependencies be npm install <package> --save-dev?

Max16:04:48

Not if it’s a maven/deps package

thheller17:04:47

@max.r.rothman the distinction is not necessary. the builds decide what is included and as such having extra but unused dependencies on the classpath do not matter

thheller17:04:56

just include everything all the time. shadow-cljs.edn itself does not have the concept of dev-dependencies.

Max17:04:52

Does that happen at all optimization levels? And how then do I configure a build to not include that code (or to only include that code in one build)?

thheller17:04:41

you ns :require forms control what the build will actually use for all optimization levels

thheller17:04:15

the build reports will tell you in detail what your build included https://shadow-cljs.github.io/docs/UsersGuide.html#build-report

Max17:04:19

Nice! 🪄

Max17:04:55

Sounds like there’s not a way to make certain namespaces or dependencies unavailable in certain builds though? I’d have to figure out some way of scraping the build report if I wanted to check that constraint automatically?

thheller17:04:08

you could also verify with a build hook. in general you want to include dev-only code via :preloads. they are not included in the release builds

👍 6
thheller17:04:29

most cljs libs already provide instructions to do so, if that applies

cbc18:04:40

hello, i'm new and i'm using shadow-cljs with cursive, and i can't get command completion to work for a js (actually typescript) library that i installed with npm...should there be a way to make this work?

cbc18:04:35

i created the project using the pom.xml as detailed here: https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive

thheller20:04:56

no, this is currently not support by Cursive

wilkerlucio20:04:58

you must use a deps.edn or a project.clj to setup things for Clojure in Cursive

Azzurite20:04:41

@U01T8T8BL9F with Cursive it's best to use deps.edn or leiningen project.clj for defining dependencies instead of shadow-cljs.edn

cbc22:04:35

ok, thanks everyone, i will give it a try...for now i'm just living with all the unresolved symbols

thheller07:04:20

pom.xml works fine, you do NOT need to use deps.edn or project.clj for Cursive. Regardless of what you use though Cursive does not support JS dependencies as of now

rkiouak16:04:52

in my experience, there is definitely no need to manage dependencies in deps or project.clj, just want to echo thhellers comment (I find that managing npm deps in shadow-cljs.edn is FAR less maintenance work than dealing with deps.edn or project.clj finagling I end up doing when working with npm deps in those)

Jason21:04:01

Does anyone have any experience building a project with Bazel? Apparently the best angle is to use the Closure rules but does that mean I should npm install shadow-cljs or clojurescript itself?