Fork me on GitHub
#babashka
<
2024-02-12
>
Dzedas Patapovas09:02:47

Hello i need some help with the strange code behaviour

(ns shell
  (:require [babashka.process :as p]))

(comment
  (p/shell "echo test")
  )
i get this error: java.io.IOException: CreateProcess error=2, file not found user c:\Users\Dzedas\source\repos\shelltest\src\shell.clj:1:1 im on windows , it works on @pez Mac.

1
borkdude09:02:41

echo is probably not an executable on Windows?

borkdude09:02:23

you can try (babashka.fs/which "echo") - if it doesn't return an executable, then that's the answer

pez10:02:22

Indeed. We get nil on Dzedas’ machine for that which expression, and we get the expected path on my machine. However, echo Hello works fine on the command prompt. Even for a Windows-y command like dir we have this strange behaviour, with shell not working and nil returned for (babashka.fs/which "dir").

borkdude10:02:04

command prompt = cmd.exe or powershell?

borkdude10:02:27

process calls out to an executable, it does not invoke powershell

borkdude10:02:15

if you want to call out to powershell, do something like:

(p/shell "pwsh -c 'echo dude'")
or whatever the syntax for that is

pez10:02:55

Gotcha. Indeed it works fine for the executable we actually want to run. 😃 Thanks!

👍 1
Shantanu Kumar12:02:40

Hi, from Babashka script a.clj I want to refer to another script b.clj (e.g. (require 'b)) - can anyone tell me how to do this? How can I specify the classpath for looking up other scripts? Do both scripts need to be in the same directory?

Shantanu Kumar12:02:44

Would be great if anyone can point me to an example.

borkdude12:02:31

Add a bb.edn file, with :paths ["."] if the script is in the root directory, if not, add :paths ["src"] or so