Fork me on GitHub
#babashka
<
2023-08-03
>
dominic13:08:58

Hi! I’m running babashka on the CI and trying to shell out to the aws CLI tool for something and getting a Message: Cannot run program "aws": error=2, No such file or directory , but earlier in my script I do call the aws tool directly, which suggest babashka doesn’t have access to the same path or something? What’s the best way to figure out what’s going on?

borkdude13:08:57

Try to run (fs/which "aws") and see what it returns, compared to (sh "which aws")

dominic13:08:52

OK, fwiw I’m using babashka.process/sh

borkdude13:08:39

yeah, that's fine

dominic13:08:35

first one outputs nothing and second one {:proc #object[java.lang.ProcessImpl 0x32381f4b "Process[pid=557, exitValue=1]"], :exit 1, :in #object[java.lang.ProcessImpl$ProcessPipeOutputStream 0x3957dc8c "java.lang.ProcessImpl$ProcessPipeOutputStream@3957dc8c"], :out "", :err "", :prev nil, :cmd ["which" "aws"]}

dominic13:08:39

so either way it’s not finding it

borkdude13:08:19

then I suspect the aws binary is not on the PATH

dominic13:08:26

gonna run it again and call which aws from the script itself

dominic13:08:33

oh, I think maybe I am just being silly, thanks 😅

dominic13:08:39

(I’ve just clocked the output of the “previous use of aws” gets sent to a file, so it’s probably failing and writing that to a file which is why I don’t see the original failure)

dominic14:08:18

OK I was wrong about that - I’ve found out the aws tool is installed on the container using pip, so aws is actually a script not a binary 🤯

dominic14:08:37

I’m assuming that’s why shelling out to it doesn’t work? :thinking_face:

borkdude14:08:37

if which aws doesn't return anything, then it's simply not on the path.

borkdude14:08:26

Maybe you can find something here. I simply googled for "pip aws path" https://stackoverflow.com/questions/23332147/awscli-not-added-to-path-after-installation

dominic16:08:43

thank you I’ve fixed my issue now (installed it differently) - and I now know to start with which X to debug any such issues in the future 😄

👍 2
Dallas Surewood22:08:17

How do I get (process) to print to the REPL and not the terminal? It seems like this gets it working for the terminal

(process {:in :inherit
          :out :inherit
          :err :inherit} "npx tailwindcss...")
But I thought *out would work to get it to the REPL
(process {:in :inherit
          :out *out*
          :err *out*} "npx tailwindcss...")
But there's no output with this

borkdude22:08:27

printing to *out* is buffered, this is why you don't see output in real time. perhaps this trick works: https://twitter.com/borkdude/status/1628786679447269377/photo/1 There is some stuff around this in this discussion too: https://github.com/babashka/process/discussions/102

Dallas Surewood22:08:13

Does the REPL not automatically read buffered output? Or does println automatically read through *out*

borkdude22:08:15

It's sleep time here, hopefully someone else can help, else I'll be back tomorrorw

Dallas Surewood22:08:54

Thanks for the threads!

Bob B23:08:37

What do you mean by "print to the REPL"? And is npx doing fancy stuff? If I do

(process {:out *out*} "ls")
I get output as though I had used println

borkdude07:08:47

@U013JFLRFS8 your example works because the ls output is closed and then it's printed. closing forces a flush