Fork me on GitHub
#babashka
<
2022-01-28
>
vinurs07:01:51

hello, i have a tmux session called test, i want to use babashka to attach the session

(shell/sh "tmux" "attach-session" "-t" "test")
it shows the error
{:exit 1, :out "", :err "open terminal failed: not a terminal\n"}
how can i do?

borkdude07:01:10

Use babashka process with inherit true

vinurs07:01:31

(-> (process ["tmux" "attach-session" "-t" "test"] {:inherit true}) check)
maybe should use like this, thanks

👍 1
Ian Fernandez20:01:21

bb.edn supports aliases?

1
borkdude20:01:11

@U9ABG0ERZ It doesn't. Why do you need this?

Ian Fernandez20:01:01

I have a task that have the deps for run it, but I want to have an easier way to run a repl without running the execution on task itself

borkdude20:01:45

maybe just add the deps to the top level :deps?

Ian Fernandez20:01:30

It would be good to have the deps only for a certain path that I load

Ian Fernandez20:01:43

that runs 1 script

Ian Fernandez20:01:04

I have 2 tasks primarly

borkdude20:01:32

for the repl you could make a script repl.clj and put (babashka.deps/add-deps '{:deps ...}) in it, and load that in the REPL

Ian Fernandez20:01:33

A & B A should not load the deps that B needs

Ian Fernandez20:01:03

something like this

borkdude20:01:16

having more dependencies on the bb classpath doesn't affect performance, unless you really load those namespaces

borkdude20:01:27

so usually it's ok to add all of them to :deps

borkdude20:01:24

but you can load those deps in the REPL dynamically too

borkdude20:01:30

with said function

👍 1
Ian Fernandez20:01:09

yeah, should be better to load it from deps.edn

Frank Henard21:01:32

Does anyone know of a way to pull a dependency from an s3 repository for babashka? We use the s3-wagon-private leiningen plugin to deploy the library. The url looks something like this

borkdude21:01:17

Should work the same as with deps.edn , only then in bb.edn

Rob Haisfield23:01:33

I’m trying to use fs/create-file, but I only seem to be able to get it to work when it’s a file from within my project folder. Is it possible to create files in directories outside of my project folder?

borkdude23:01:53

Sure, you just need to provide an absolute path and create parent directories with fs/create-dirs

borkdude23:01:27

So something like

(doto (fs/file "/tmp/foo/bar/baz") (-> fs/parent fs/create-dirs) fs/create-file)

Rob Haisfield18:02:36

I’m confused… why do I need to create new parent directories?

borkdude19:02:23

if you are writing a file /tmp/foo/bar/baz but the parent directories do not exist, then you need to create them first. if they already exist, then it should just work without creating those.

Rob Haisfield19:02:55

Yeah they should already exist… but when I run these functions it returns false. Would this be a system permissions thing for my code editor?

borkdude19:02:35

I get the confusion. ~ isn't expanded, but there is an expand-home function for this

borkdude19:02:48

~ is a bash thing really, not a Java or Clojure thing

Rob Haisfield19:02:58

Ah I see… Got it. Still have an issue though - I’ve got the recent version of fs in my project dependencies, but now when I try to run that function, it says No such var: fs/expand-home

Rob Haisfield19:02:50

(fs/expand-home "~/Dropbox/Notes/Test/")

borkdude19:02:57

can you paste a complete project.clj here? then I can try it locally? you can remove almost anything but the :dependencies

Rob Haisfield19:02:35

(defproject functions-for-processing-notes "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :dependencies [[org.clojure/clojure "1.10.3"]
                 [dk.ative/docjure "1.14.0"]
                 [com.rpl/specter "1.1.3"]
                 [babashka/fs "0.1.2"]
                 [orchestra "2021.01.01-1"]
                 [lambdaisland/deep-diff2 "2.0.108"]
                 [org.clojars.arthurbarroso/lovelace "0.1.2"]]

  :repl-options {:init-ns functions-for-processing-notes.core})

borkdude19:02:05

functions-for-processing-notes.core=> (require '[babashka.fs :as fs])
nil
functions-for-processing-notes.core=> (fs/expand-home "~/Dropbox/foo")
#object[sun.nio.fs.UnixPath 0x628c30e8 "/Users/borkdude/Dropbox/foo"]

borkdude19:02:25

works here...

Rob Haisfield16:02:08

Weird… these are the only options that show up for me on autocomplete too

borkdude16:02:48

which editor / environment is this? it might be an older version of babashka

borkdude16:02:07

or are you using babashka.fs on the JVM?

borkdude16:02:20

sorry I lose track of 10s of conversations happening interleaved ;)

Rob Haisfield16:02:49

Yes, I’m using babashka.fs on the JVM in Calva

Rob Haisfield16:02:58

No worries! I appreciate the help you’re giving me

borkdude16:02:26

ok, if you have the newest version then you should be seeing that function.

Rob Haisfield16:02:52

[babashka/fs "0.1.2"] is that not the newest version?

borkdude16:02:37

it is. I don't know why the tooling doesn't show you that function

Rob Haisfield16:02:07

It’s not just that the tooling isn’t showing the function… when I try to eval, it says No such var: fs/expand-home

borkdude16:02:17

In emacs CIDER it is showing correctly:

borkdude16:02:40

ok, then something is clearly wrong with your dependencies. :)

borkdude16:02:24

What do you see for (System/getProperty "java.class.path")

borkdude16:02:49

don't paste the entire output here, but only the part that is concerning babashka.fs

Rob Haisfield17:02:31

jar:/Users/roberthaisfield/.m2/repository/babashka/fs/0.0.5/fs-0.0.5.

Rob Haisfield17:02:46

Hmm why would it have that if my dependencies has the correct version?

borkdude17:02:49

ok, so this is a pretty old version of babashka.fs, there you have it :)

borkdude17:02:09

try lein deps :tree to see what else might be pulling in babashka fs.

borkdude17:02:22

maybe you're using a lein profile. who knows.