I’m having a strange problem with babashka fs. I’m trying to access some files under /tmp using the glob function. (fs/list-dir "tmp") returns all the files in /tmp, including the ones I’m seeking, but (fs/glob "/tmp" "*") returns an empty vector. Any ideas what’s going on here? I’m on MacOS 15.4.1 if that matters.
can you give an example of the file that is inside the dir you expect to appear?
Sure, I was originally trying to find files like app.js.map and common.js.map using the glob command (fs/glob "/tmp" "*.js.map") , but I discovered that even (fs/glob "/tmp" "*") returns no files even though there are plenty in the directory.
have you tried *.*?
*.* also returns no results.
I tried using a subdirectory under my home directory and it works, so I’m wondering if MacOS is doing some security thing with /tmp
hmm, in my case it does work correctly:
$ bb -e '(fs/glob "." "*")'
[#object[sun.nio.fs.UnixPath 0x5f407522 "MozillaUpdateLock-2656FF1E876E9973"] #object[sun.nio.fs.UnixPath 0x1c5d5111 "test.xt"] #object[sun.nio.fs.UnixPath 0x3fdade3d "script.clj"] #object[sun.nio.fs.UnixPath 0x1d1bc3c4 "dude.mjs"] #object[sun.nio.fs.UnixPath 0x18d17fea "ana-wip.edn"] #object[sun.nio.fs.UnixPath 0x6a310cbb "dude.cljc"] #object[sun.nio.fs.UnixPath 0x6bba902b "test.txt"] #object[sun.nio.fs.UnixPath 0xd0372e6 "dude.txt"] #object[sun.nio.fs.UnixPath 0x282c67b "clojure-lsp.out"]]Can you try "/tmp" instead of "."?
ah gotcha:
$ bb -e '(fs/glob "/tmp" "*")'
[]
I think this is because /tmp/ is a symlinkOhhh
bb -e '(fs/glob (fs/real-path "/tmp") "*")'Yeah when I use {:follow-links true} it works. That’s a bit of a sharp edge. I assumed links only mattered for children of root, not for root itself.
or:
bb -e '(fs/glob "/tmp" "*" {:follow-links true})'Thanks for your help!
I agree it's a sharp edge.