Fork me on GitHub
Flavio Barros13:08:01

Hello all! I am a beginner and I'm having a hard time with clojurescript and lein.

Flavio Barros13:08:03

I just installed everythin, lein is working with a vanilla clojure project, I can access repl, but when I start a new project with figwhell I can't run it. I created a project with:

Flavio Barros13:08:34

lein new figwheel my-web -- --reagent

Flavio Barros13:08:53

and after that entered my-web and installed all js dependencies

Flavio Barros13:08:23

lein figwheel

Flavio Barros13:08:35

I receive the following error:

Flavio Barros13:08:02

Figwheel: Cutting some fruit, just a sec ... Figwheel: Validating the configuration found in project.clj Figwheel: Configuration Valid ;) Figwheel: Starting server at Figwheel: Watching build - dev Compiling build :dev to "resources/public/js/compiled/out/index.js" from ["src"]... Failed to compile build :dev from ["src"] in 1.547 seconds. ---- Exception ---- clojure.lang.ExceptionInfo : :build-cmd :none failed .IOException : Cannot run program "npx": error=2, Arquivo ou diretório inexistente .IOException : error=2, Arquivo ou diretório inexistente


Is npx installed? If not you may need to try sudo npm i -g npx Your questions sounds like it rather belongs to #clojurescript or #figwheel channel instead. Try asking there instead if npm i didn't work.


Also, I'm a bit biased on this one but you can probably give luminus template a try instead of "figwheel" template. There is a chance that's it is more up to date. there is "+cljs" profile hint as well

Flavio Barros03:08:35

thank you @U0113AVHL2W I am still finding my way over these tools. But from my research maybe shadow-cljs should be easier to work with. I gave up on this

Flavio Barros13:08:20

but I didn't anything. Should be working right???

Flavio Barros13:08:14

My lein version: Leiningen 2.9.4 on Java 11.0.7 OpenJDK 64-Bit Server VM


Is there a method to stub a function in java.lang.System ns? "exit" to be exact Attempted this snippet:

(with-redefs-fn [java.lang.System/exit (fn [x] (println "stubbed exit with status code" x))]
    (java.lang.System/exit 0))
It fails with: > Unable to find static field: exit in class java.lang.System The original motivation is to stub "exit" call in third-party package while I'm using it from REPL? That's cljfmt


I may not be familiar with how you are using the word “stub” here. You want to redefine the behavior of the Java exit method?


If so, Clojure does not provide a way to redefine JVM methods


With-redefs-fn is for redefining Clojure functions, not Java methods


I do not know if the JVM’s exit method is possible to redefine, or if so, how one might do it


The JVM documentation for the exit method mentions shutdown hooks, with a link to a method that allows you to add shutdown hooks, which appear to be called shortly before the JVM actually exits, but after exit is called


@U0CMVHBL2 thank you! 🙏


you can only redef vars, not methods/fields


This one seems to worked fine for stubbing a method:

(with-redefs [cljfmt.main/exit (fn [x] (println "aborting exit: " x))]
    (#'cljfmt.main/check '("/tmp/delete/project.clj") cljfmt.main/merge-default-options))
> :profiles/test {}}) > 1 file(s) formatted incorrectly > aborting exit: {:okay 0, :incorrect 1, :error 0}


that's a var


This portion of the Clojure docs doesn't seem very clear to me

;; What is inside the (commment ...) is readable, so no error for this,
;; and no code will be generated by the compiler.
(defn foo [x]
  (inc x))

;; What is inside the (comment ...) is NOT readable, so this will give an error
a : b
Is there really a (commment ...) form (with 3 m) or is that just a typo??

Alex Miller (Clojure team)20:08:09

just fyi, clojuredocs is a community web site with community submitted examples, not official documentation

👌 3

oh okay. thanks @alexmiller 🙏

Alex Miller (Clojure team)20:08:28

it's mostly very helpful :)


I guess I can just find the repo on github and fix that then simple_smile

Alex Miller (Clojure team)20:08:57

you can probably file an issue there

👍 3
Michael W23:08:18

How do a create a date inst programattically? (let [s "1980-01-01"] #inst s) Syntax error reading source at (REPL:2:10). class clojure.lang.Symbol cannot be cast to class java.lang.CharSequence (clojure.lang.Symbol is in unnamed module of loader 'app'; java.lang.CharSequence is in module java.base of loader 'bootstrap')


here I think you could either do (let [s #inst "1980-01-01"] s) or (let [s "1980-01-01"] (clojure.instant/read-instant-date s)

Michael W00:08:45

Thanks read-instant-date was what I needed