This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-16
Channels
- # announcements (3)
- # babashka (48)
- # beginners (35)
- # calva (3)
- # chlorine-clover (5)
- # clj-kondo (9)
- # cljdoc (20)
- # cljsrn (1)
- # clojure (55)
- # clojure-europe (33)
- # clojure-nl (3)
- # clojure-norway (6)
- # clojure-spec (7)
- # clojure-uk (27)
- # clojurescript (95)
- # closh (1)
- # conjure (1)
- # cursive (16)
- # datomic (30)
- # emacs (7)
- # honeysql (1)
- # hugsql (2)
- # introduce-yourself (2)
- # jobs (1)
- # lsp (30)
- # malli (22)
- # nbb (11)
- # news-and-articles (1)
- # off-topic (8)
- # pathom (21)
- # polylith (41)
- # portal (4)
- # practicalli (4)
- # protojure (1)
- # re-frame (14)
- # releases (1)
- # restql (1)
- # reveal (24)
- # sci (1)
- # sql (21)
- # vim (11)
- # xtdb (33)
Hello, I wanted to do a task that watch some files and execute some commands when they are modified. I did not find something in the babashka libraries; I noticed that there are two pods providing that feature; one implementation in rust and another one in go (this one seems broken though). Are there the only options available? I tried to implement something basic using java interop but it seems that I miss the class StandardWatchEventKinds (https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/StandardWatchEventKinds.html#ENTRY_CREATE)... I really want to avoid using another scripting language to monitor file changes: is there something I can from babashka?
Let us know what kind of errors youre facing with the pods, we would try to address them 🙂
I did not encounter an error per se with fswatcher; https://github.com/fsnotiy/fsnotify is a 404 and so I thought that the whole project was stopped... sorry I was not clear.
Now I tried fswatcher; the first thing I had to do was to build the project: that was easy enough. The binary was installed in my user directory pods repository but when I tried a sample code it failed
clojure.lang.ExceptionInfo: C:\Users\Mandimby\.babashka\pods\repository\org.babashka\fswatcher\0.0.1\pod-babashka-fswatcher.exe
{:type :sci/error, :line 4, :column 1, :message "C:\\Users\\Mandimby\\.babashka\\pods\\repository\\org.babashka\\fswatcher\\0.0.1\\pod-babashka-fswatcher.exe", :sci.impl/callstack #object[clojure.lang.Delay 0x120e9e54 {:status :pending, :val nil}], :file "c:/data/projects/sandbox/adabox-macropad/scripts/watch_file_changes.clj", :locals {}}
at sci.impl.utils$rethrow_with_location_of_node.invokeStatic (utils.cljc:71)
sci.impl.evaluator$eval.invokeStatic (evaluator.cljc:329)
sci.impl.interpreter$eval_form.invokeStatic (interpreter.cljc:78)
sci.core$eval_form.invokeStatic (core.cljc:268)
babashka.nrepl.impl.server$eval_msg$fn__33669$fn__33670.invoke (server.clj:61)
...
com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine (WindowsJavaThreads.java:138)
Caused by: java.nio.file.AccessDeniedException: C:\Users\Mandimby\.babashka\pods\repository\org.babashka\fswatcher\0.0.1\pod-babashka-fswatcher.exe
at sun.nio.fs.WindowsFileSystemProvider.implDelete (WindowsFileSystemProvider.java:274)
sun.nio.fs.AbstractFileSystemProvider.deleteIfExists (AbstractFileSystemProvider.java:110)
java.nio.file.Files.deleteIfExists (Files.java:1181)
java.nio.file.Files.copy (Files.java:3055)
babashka.pods.impl.resolver$unzip.invokeStatic (resolver.clj:60)
babashka.pods.impl.resolver$resolve$fn__31852.invoke (resolver.clj:182)
clojure.core$mapv$fn__8470.invoke (core.clj:6937)
...
com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine (WindowsJavaThreads.java:138)
Now to give more context I am working on a side project on windows 10 (not wsl) and "native" babashka works perfectly.
A pod requires a extra binary to be installed. Filewatcher only provides release binaries for macos and linux... I cannot use it as is;
> Caused by: java.nio.file.AccessDeniedException: Not sure what causes this, but I've seen a user of clj-kondo also report an AccessDeniedException, he had to change the permissions of the executable somehow. I don't know why
Im making the change in the broken link to fsnotify in the readme. thanks for spotting it
@U04V15CAJ Indeed the example in https://github.com/babashka/pod-registry/blob/master/examples/fswatcher.clj worked without any issue
Thank you all for the swift replies
@mandimby.raveloarinja Cool. Is there anything that should change to the docs to make it clearer?
I am not sure, it was not obvious for me that requiring the pod will download the required binary but now testing the example script shows it clearly
Now I am not sure whether this is the case for any of the pod that expect an external bianary
I guess it might be on a case by case basis
It is true for any pod that you load with (load-pod <fully qualified symbol> <version>)
. there might still be pods around that don't have a windows version, but this can be easily fixed
@mandimby.raveloarinja Here am I using the Rust one to watch for asciidoc changes to rebuild the book and then trigger an update to watch it with etaoin: https://github.com/babashka/book/blob/master/script/watch.clj
Thank you for the sample code. I am running babashka on windows (not wsl) and filewatcher does not provide a native windows binary. I would have to compile it from source... that is not what I want to tackle at the moment and that is why I was hopping for something I can craft natively in babashka
FYI: https://github.com/google/zx (saw on hacker news)
I was working on some babashka code, I found that the error messages werent leading me to my problem... for example,
(defn jimmy [ jj ] )
(defn josh [ zy ] (jimmy)) ;; wrong arity
(defn foo [ x ] (josh 7))
(def handler foo) ;; error message points here
(defn boo [ j ] (handler) )
(boo 7)
clojure.lang.ExceptionInfo: Wrong number of args (0) passed to: user/handler
{:type :sci/error, :line 7, :column 18, :message "Wrong number of args (0) passed to: user/handler", :sci.impl/callstack #object[clojure.lang.Delay 0x128c830a {:status :pending, :val nil}], :file "/home/bob/jim.bb", :locals {j 7}}
at sci.impl.utils$rethrow_with_location_of_node.invokeStatic (utils.cljc:71)
...
It seems like the error tracking stops once a dynamic var (handler) is in the stack. Is there a way to make the error messages better? (babashka v0.5.1)are you already using clj-kondo? you would have spotted this mistake before even executing the script.
when invoking the script I get:
$ bb /tmp/dude.clj
----- Error --------------------------------------------------------------------
Type: clojure.lang.ArityException
Message: Wrong number of args (0) passed to: user/handler
Location: /tmp/dude.clj:5:18
----- Context ------------------------------------------------------------------
1: (defn jimmy [ jj ] )
2: (defn josh [ zy ] (jimmy)) ;; wrong arity
3: (defn foo [ x ] (josh 7))
4: (def handler foo)
5: (defn boo [ j ] (handler) )
^--- Wrong number of args (0) passed to: user/handler
6: (boo 7)
----- Locals -------------------------------------------------------------------
j: 7
----- Stack trace --------------------------------------------------------------
user/handler - /tmp/dude.clj:4:6
user/boo - /tmp/dude.clj:5:18
user/boo - /tmp/dude.clj:5:1
user - /tmp/dude.clj:6:1
So this is a simplified example, and the functions are in different namespaces... I did run clj-kondo, but it didnt seem to pick up these issues. Probably worth mentioning that handler is assigned dynamically (based actually on the incoming url)
clj-kondo reported this one: (defn josh [ zy ] (jimmy)) ;; wrong arity
, I thought you meant that one
I refactored some code and I hit about 20 of these issues in my code, and spent hours adding printlns to find where I messed up the arity.
anything below the handler and it is like the error is saying "there is an arity error somewhere, good luck."
I think this might be because (def x y)
assigns the value of y to x but the metadata from y doesn't apply to x
> I'm open to a hack that copies the metadata or some such... I might not, as this might affect performance somehow, but we'll see ;)
this will at least give the proper name:
(defn foo [])
(def h foo)
(alter-meta! #'h (constantly (meta #'foo)))
(h 1 2 3)
I did not encounter an error per se with fswatcher; https://github.com/fsnotiy/fsnotify is a 404 and so I thought that the whole project was stopped... sorry I was not clear.
Now I tried fswatcher; the first thing I had to do was to build the project: that was easy enough. The binary was installed in my user directory pods repository but when I tried a sample code it failed
clojure.lang.ExceptionInfo: C:\Users\Mandimby\.babashka\pods\repository\org.babashka\fswatcher\0.0.1\pod-babashka-fswatcher.exe
{:type :sci/error, :line 4, :column 1, :message "C:\\Users\\Mandimby\\.babashka\\pods\\repository\\org.babashka\\fswatcher\\0.0.1\\pod-babashka-fswatcher.exe", :sci.impl/callstack #object[clojure.lang.Delay 0x120e9e54 {:status :pending, :val nil}], :file "c:/data/projects/sandbox/adabox-macropad/scripts/watch_file_changes.clj", :locals {}}
at sci.impl.utils$rethrow_with_location_of_node.invokeStatic (utils.cljc:71)
sci.impl.evaluator$eval.invokeStatic (evaluator.cljc:329)
sci.impl.interpreter$eval_form.invokeStatic (interpreter.cljc:78)
sci.core$eval_form.invokeStatic (core.cljc:268)
babashka.nrepl.impl.server$eval_msg$fn__33669$fn__33670.invoke (server.clj:61)
...
com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine (WindowsJavaThreads.java:138)
Caused by: java.nio.file.AccessDeniedException: C:\Users\Mandimby\.babashka\pods\repository\org.babashka\fswatcher\0.0.1\pod-babashka-fswatcher.exe
at sun.nio.fs.WindowsFileSystemProvider.implDelete (WindowsFileSystemProvider.java:274)
sun.nio.fs.AbstractFileSystemProvider.deleteIfExists (AbstractFileSystemProvider.java:110)
java.nio.file.Files.deleteIfExists (Files.java:1181)
java.nio.file.Files.copy (Files.java:3055)
babashka.pods.impl.resolver$unzip.invokeStatic (resolver.clj:60)
babashka.pods.impl.resolver$resolve$fn__31852.invoke (resolver.clj:182)
clojure.core$mapv$fn__8470.invoke (core.clj:6937)
...
com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine (WindowsJavaThreads.java:138)
Now to give more context I am working on a side project on windows 10 (not wsl) and "native" babashka works perfectly.
A pod requires a extra binary to be installed. Filewatcher only provides release binaries for macos and linux... I cannot use it as is;