clojurescriptingbabashka

Going up a directory in babashka


I am trying to traverse the fp in babashka, and have found that running (shell "cd ..") in my script bb-test causes an error:

----- Error --------------------------------------------------------------------
Type:     java.io.IOException
Message:  Cannot run program "cd": error=2, No such file or directory
Location: /home/jack/Documents/clojure/leingit/./bb-test:120:1

Any ideas?


Solution

  • You can't change the working directory in babashka (it is a limitation that comes from being a JVM-derived environment). But you can spawn new processes in other directories:

    (require '[babashka.process :refer [shell]])
    
    (shell {:dir ".."} "whatever")