This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-02
Channels
- # announcements (3)
- # asami (29)
- # babashka (62)
- # beginners (131)
- # biff (7)
- # calva (31)
- # cider (5)
- # clerk (14)
- # clj-kondo (3)
- # cljsrn (12)
- # clojars (18)
- # clojure (72)
- # clojure-austin (17)
- # clojure-dev (6)
- # clojure-europe (31)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-norway (18)
- # clojure-sweden (11)
- # clojure-uk (6)
- # clr (47)
- # conjure (42)
- # cursive (88)
- # datalevin (2)
- # datomic (25)
- # emacs (42)
- # exercism (1)
- # fulcro (10)
- # funcool (8)
- # gratitude (2)
- # honeysql (16)
- # introduce-yourself (5)
- # jobs-discuss (26)
- # leiningen (5)
- # lsp (31)
- # malli (21)
- # matcher-combinators (14)
- # missionary (2)
- # nbb (1)
- # off-topic (40)
- # pathom (38)
- # portal (2)
- # re-frame (7)
- # reagent (18)
- # reitit (1)
- # releases (5)
- # shadow-cljs (62)
- # sql (12)
- # testing (4)
- # xtdb (37)
Can I restore the 1.1.170 behaviour of printing the script results in some backward compatible way? 1.1.170 doesn't like the --prn
option.
How are you using it? It should be used as a global option, ie one of the first things you pass
I tried with a shabang on my script, like so:
#!/usr/bin/env -S bb --prn -cp ./bin
Works fine with 171. With 170 I get
Message: File does not exist: --prn
My script blows up in 171 (for reasons I am investigating) and it is completely silent. With --prn
the error and stack trace is printed.
That sounds like a try/catch which then returns the exception as a value which then gets printed
Hmmm, it blows up silently with or without --prn
, (it's a shell-out). I added an explicit throw when I get non-zero exit value. Maybe that gets returned...
I'm using java/shell
. It's an old script. Has been ticking along since very long and suddenly stopped doing anything some week ago.
—prn does nothing else than print the last value like the old version did. It has no impact on error reporting. If you use an explicit ‘prn’ on the last value then behaviour should be 100% the same in both versions
wow, I didn't know about the env -S
trick - is that to support multiple args?
It seems it started working on linux a few years ago, but it wasn't cross platform before. https://unix.stackexchange.com/a/477651/28294
I am using bb tasks and trying to pull in a github repo, how ever I am getting Error building classpath. Unable to clone, and fatal: could not read Username for 'https://github.com': terminal prompts disabled. the only thing I notice is it says username and not organisation but perhaps they are treated the same. any idea's on what may cause this ?
Well that's what the error means, without any idea of what you're doing code-wise we can't offer any more help 🙂
{:paths ["bb"]
:deps {io.github.organisation/build-tools {:git/sha "mysha"}}
:tasks
{}}
basically that, then running bb tasksThe difference is that's not how you define a git dep 😉 Probably couldn't infer the repo from the name
lol, I got that from https://clojure.org/guides/deps_and_cli#_using_git_libraries 🙂
Yeah, io.github.*
should work :thinking_face:
Maybe babashka doesn't support it?
fair enough I did look in the babashka book for an example, it works now so thanks for the assistance 🙂
Let's say I'm writing a tool called magic
(which is actually true). I want to have a proper setup with bb.edn and namespace declarations, so here's the folder structure:
.
├── bb.edn
├── bin
│ └── magic
└── src/magic
└── main.clj
Now I want to have a single script to call. This works:
#!/usr/bin/env bash
set -euo pipefail && cd "$(dirname "${BASH_SOURCE[0]}")/.."
exec bb -m magic.main "[email protected]"
Now I can call magic
from anywhere with a single command. However, in this way of doing things, the CWD (current working directory) is set to the root folder of the project (that's what cd
does in the script). Oftentimes I want to keep the CWD, for instance if magic
is to operate on files in the current folder.
What's a good way to do this?Maybe install the script in the system with https://github.com/babashka/bbin and allow the script to use current folder (by default) and have a -f
option to pass an optional folder?
Or make a bash wrapper which sets:
bb --config "$(dirname "${BASH_SOURCE[0]}")/../bb.edn" -m magic.main "[email protected]"
but bbin works cross platformI am considering setting the --config
flag automatically when you execute a script outside of the current directory, so it picks up on the bb.edn
of the script, but I'm not sure if this will break any existing setups. Also this would only work for *nix, not on Windows, and bb aims to be a cross-platform tool. So in the end, bbin is the preferred solution.
Alternatively use https://direnv.net/.
Create $PROJECT_ROOT/.envrc
with
PATH_add bin
export PROJECT_ROOT=$(expand_path .)
Then from anywhere in or under $PROJECT_ROOT you’ll have magic
on PATH
The script itself would then have bb --config "${PROJECT_ROOT}/bb.edn" -m magic.main "[email protected]"
For my latest scripts, I’ve copied the folder structure from https://github.com/borkdude/carve.
1. All dependencies are in deps.edn
2. bb.edn
refers to deps.edn
dependencies
3. bb.edn
also gives a bbin directive for what I want the binary to be called.
For local installation, I install with bbin install .
or bbin install . --as myscript-dev
if I want both a local binary and a proper install.
Local installs automatically pick up any changes to your script, so it’s very easy make a change, run it again, etc; you don’t need to re-run bbin install
.
The “carve structure” also makes it possible to REPL into your project with both babashka and clojure.
what about adding /path/to/src/ to bb classpath? This way you dont need to change the cwd to call bb -m magic.main?
but all deps in path/to/project should also be added, which is what --config
is for
Thanks for all the suggestions.
--config
does exactly what I was looking for
cljfmt master now works with bb:
bb -Sdeps '{:deps {cljfmt/cljfmt {:git/url "" :git/sha "7dfd55d5dd0756f30311a90f206c2dd32e56d18b" :deps/root "cljfmt"}}}' -m cljfmt.main

Added cljfmt
to my bbin tools collection:
https://github.com/borkdude/tools#cljfmt
not sure what I am doing wrong:
$ bbin --version
bbin 0.1.8
$ bbin install
{:coords
#:bbin{:url
""}}
$ cljfmt --help
zsh: command not found: cljfmt
@U051GFP2V Do you have a fully functioning bbin installation?
In babashka tasks is there an idiomatic way to prevent dependent tasks from rerunning when nothing has changed? filewatcher ?
Here is a blog about that: https://blog.michielborkent.nl/speeding-up-builds-fs-modified-since.html