babashka

2025-05-05T18:18:45.777339Z

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.

borkdude 2025-05-05T18:22:42.879679Z

can you give an example of the file that is inside the dir you expect to appear?

2025-05-05T18:26:18.246249Z

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.

borkdude 2025-05-05T18:26:38.863309Z

have you tried *.*?

2025-05-05T18:27:05.177119Z

*.* also returns no results.

2025-05-05T18:27:40.573389Z

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

borkdude 2025-05-05T18:27:55.320859Z

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"]]

2025-05-05T18:28:24.935459Z

Can you try "/tmp" instead of "."?

borkdude 2025-05-05T18:28:36.364999Z

ah gotcha:

$ bb -e '(fs/glob "/tmp" "*")'
[]
I think this is because /tmp/ is a symlink

2025-05-05T18:28:45.876229Z

Ohhh

borkdude 2025-05-05T18:28:55.385989Z

bb -e '(fs/glob (fs/real-path "/tmp") "*")'

2025-05-05T18:31:41.048629Z

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.

borkdude 2025-05-05T18:31:42.074909Z

or:

bb -e '(fs/glob "/tmp" "*" {:follow-links true})'

2025-05-05T18:32:50.361199Z

Thanks for your help!

borkdude 2025-05-05T18:33:02.274019Z

I agree it's a sharp edge.