This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-02
Channels
- # announcements (6)
- # babashka (21)
- # beginners (38)
- # biff (2)
- # calva (14)
- # cider (5)
- # clerk (4)
- # cljdoc (2)
- # clojure (11)
- # clojure-europe (2)
- # clojure-norway (5)
- # clojure-spec (4)
- # core-typed (8)
- # data-science (5)
- # deps-new (15)
- # events (1)
- # fulcro (2)
- # graalvm (33)
- # holy-lambda (3)
- # hyperfiddle (19)
- # kaocha (1)
- # portal (5)
- # test-check (1)
- # xtdb (9)
- # yamlscript (2)
I’m having a weird problem with babashka.fs. If I run this code in the REPL it works without error:
(let [host " "
user "********"
pass "********"]
(fs/unzip (fs/file "/tmp" "CATALOG.zip") (fs/file "/tmp") {:replace-existing true}))
However, if I build an uberjar and run that, I get this error:
Exception in thread "main" java.nio.file.FileAlreadyExistsException: /tmp
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:398)
at java.base/java.nio.file.Files.createDirectory(Files.java:700)
at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
at java.base/java.nio.file.Files.createDirectories(Files.java:753)
at babashka.fs$create_dirs.invokeStatic(fs.cljc:421)
at babashka.fs$create_dirs.invoke(fs.cljc:416)
at babashka.fs$create_dirs.invokeStatic(fs.cljc:419)
at babashka.fs$create_dirs.invoke(fs.cljc:416)
at babashka.fs$unzip.invokeStatic(fs.cljc:935)
at babashka.fs$unzip.invoke(fs.cljc:925)
at scw.full_catalog_import$download_and_unzip.invokeStatic(full_catalog_import.clj:350)
at scw.full_catalog_import$download_and_unzip.invoke(full_catalog_import.clj:334)
at scw.full_catalog_import$_main.invokeStatic(full_catalog_import.clj:358)
at scw.full_catalog_import$_main.invoke(full_catalog_import.clj:356)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at scw.full_catalog_import.main(Unknown Source)
Any idea what might be causing that?according to the docs of createDirectories, that exception may be thrown if the file exists and is not a directory (/tmp in this case)
That’s what’s so strange. /tmp is a valid directory and, I don’t get that error when I run that code in the REPL.
It seems to me as if it’s trying to create “/tmp” instead of unzipping the file into that directory. Could that be the problem?
Ah, ok. So if I use (fs/file "/tmp/DATA")
, for example, it seems to work as expected.
I don't know the full mechanics of how the uberjar runs, but maybe it does something with a file called 'tmp' or something - could explain the difference in running from the repl vs an uberjar - how about if you run it via bb -f
, but not as an uberjar
Hmz, the bug comes from:
user=> (fs/create-dirs "/tmp")
Execution error (FileAlreadyExistsException) at sun.nio.fs.UnixException/translateToIOException (UnixException.java:94).
But I think this has to do with /tmp being a symlink...As create-dirs just defers to Files/createDirectories
I would argue this is standard JVM behavior
FileAlreadyExistsException - if dir exists but is not a directory (optional specific exception)
That makes sense, @U04V15CAJ since /tmp on macOS is a symlink to /private/tmp.
Thanks for the help @U013JFLRFS8 and @U04V15CAJ!
Hey. I'm having trouble marrying babashka with Cursive: I've created an empty deps project, with a single script requiring babashka.curl
, marked it as babashka script, but nevertheless Intellij won't recognize babashka.curl
, i.e. cannot resolve it and give any meaningful help with it. Could someone help?
Actually it won't resolve almost anything, ns
, defn
, etc. 0.o
I’m travelling at the moment, but check the first item here and see if that helps: https://cursive-ide.com/userguide/troubleshooting.html#help-lots-of-symbols-don-t-resolve edit: fixed link now I’m on desktop
@U5USC6WNL did you create a bb.edn
file?
Thank you for the replies!
From the top, the macro doesn't really help, as it's just everything that doesn't resolve.
The bb version is 1.3.184
And the bb.edn
file, nope.
I made it work somehow but honestly, I don't know what helped, as I tried creating bb.edn
, specifying source paths, then deleting it again, changing SDK, removing and adding babashka support to the module, etc. It worked at some point: it's not bb.edn
, as I deleted it and it still works. The only thing I can tell is: in Project View, the babashka dependency is shown correctly (as a tree node that can be expanded into separate jars); before that, it was more of an unexpandable label.
BTW, just to make sure it's my project setup, not something else, I downloaded neil
and tried to open it with Cursive, and it worked correctly from the get go.
So I guess at some point IntelliJ IDEA's state somehow got messed up (which is strange as it's literally an empty project I just created), but still. Eh.
On that note, maybe nuking .iml
file and reopening the project could help.