Fork me on GitHub
#babashka
<
2023-02-03
>
teodorlu11:02:49

Does anyone have a shell oneliner for installing both babashka and bbin that works on Linux? Something like https://rustup.rs/. bbup? Context: I want to lower the effort required to share bb scripts with colleagues who don’t use Clojure each day. I would love to have a README with something like

# My tool

## setup

    curl  | ...
    bbin install io.github.teodorlu/mytool

borkdude11:02:06

For linux and macOS you can use:

bash <(curl )

borkdude11:02:47

I notice the versions should be updated in the bbin install instructions (cc @U0CLCL6T0)

Bob B14:02:07

while not as specific as something like bbup, if brew is in use that's an option

borkdude14:02:12

good point, with brew you even have to only install bbin since that depends on babashka

teodorlu17:02:40

I threw something together: https://bbup.teod.eu/ It doesn't add the bbin folder to PATH yet. I want to do that defensively -- only modifiy bashrc and zshrc files if it's not on PATH together.

teodorlu17:02:18

Let me know if I'm stepping on any toes here, Borkdude πŸ™‚

borkdude17:02:41

not at all :) πŸ‘

borkdude17:02:39

if you click on the "view all" thing, some Rust stuff still appears

βœ… 2
πŸ‘ 2
teodorlu17:02:41

Thanks, I'll check it out πŸ‘

borkdude18:02:31

When copying the url via the UI you get a Rust url

borkdude18:02:38

I almost accidentally installed rust

πŸ˜… 2
borkdude18:02:08

When copying the url manually:

curl --proto '=https' --tlsv1.2 -sSf  | sh
/usr/bin/sh: 18: Syntax error: "(" unexpected

borkdude18:02:30

I suggest trying it from a vanilla ubuntu docker image ;)

πŸ’― 2
borkdude18:02:41

I guess it should be piped into | bash instead of sh. Also the extension suggests .sh while the script actually uses bash syntax

πŸ‘ 2
borkdude18:02:33

bbin doesn't work after install and I didn't get a message about PATH

πŸ‘ 2
borkdude18:02:34

I end up with the amd binary on arm linux, not sure why

borkdude18:02:53

user=> (System/getProperty "os.arch")
"amd64"

borkdude18:02:08

root@03ec0c99f8cb:/# uname -a
Linux 03ec0c99f8cb 5.10.76-linuxkit #1 SMP PREEMPT Mon Nov 8 11:22:26 UTC 2021 armv7l armv7l armv7l GNU/Linux

borkdude18:02:53

This appears to be in the install script

borkdude18:02:35

ah, uname -m returns armv7l

teodorlu02:02:40

As you've noticed, it doesn't quite work yet. 1. I obviously should add a message that this doesn't quite work yet to the HTML 2. I'd like to make it work under "posix sh" - so we don't need to rely on bash being installed on newer macs. I'm not 100 % sure about the subtle differences between posix sh and bash, but I think it should be doable. 3. Right now I'm not using the javascript "which platform am I using" for anything - I always download and run install.sh (https://github.com/teodorlu/bbup.teod.eu/blob/master/install.sh). 4. Not sure why you're getting an amd binary on arm linux, I'd like to avoid that. 5. Testing from Docker is a great suggestion - I've been "testing" so far with bash install.sh --dry-run, but Docker is great for testing what actually happens. 6. "When copying the url via the UI you get a Rust url, I almost accidentally installed rust". Yeah, sorry about that! It surprised me as well. The javascript code ignored the HTML content, and had hard-coded the script from a javascript constant instead. (https://github.com/teodorlu/bbup.teod.eu/commit/7867b10f1b14de0a139076abeb66fce36859a944) Thanks for testing!! πŸ™Œ

teodorlu05:02:17

@U04V15CAJ I've fixed the errors I found, and the scripts seem to be working when I'm testing with Docker. To test (again):

curl --proto '=https' --tlsv1.2 -sSf  | sh
I also made a minmal dockerfile:
$ git clone [email protected]:teodorlu/bbup.teod.eu.git
[...]
$ cd 
$ docker build -f ex4.dockerfile -t tmp . && docker run --rm -it tmp
[...]
# curl --proto '=https' --tlsv1.2 -sSf  | sh
Downloading  to /tmp/tmp.sradVD3GDy
Successfully installed bb in /usr/local/bin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 26760  100 26760    0     0  86845      0 --:--:-- --:--:-- --:--:-- 86601
bbup has detected that you are running bash
Adding

    export PATH="$HOME/.babashka/bbin/bin:$PATH"

to /root/.bashrc ...Done!
Please run

    source /root/.bashrc

or restart your shell to run Babashka or bbin.
after installing:
[root@9bd8554d4622 /]# bb -e '(inc 10)'
11
[root@9bd8554d4622 /]# source /root/.bashrc
[root@9bd8554d4622 /]# bbin install io.github.borkdude/carve
[...]
[root@9bd8554d4622 /]# carve --help
Downloading pod clj-kondo/clj-kondo (2023.01.20)
Successfully installed pod clj-kondo/clj-kondo (2023.01.20)
Carve: remove unused Clojure vars.

  --report            Set to true to report and not transform code
  --interactive       Interactive mode: ask what to do with an unused var
  --silent            When truthy, does not write to stdout. Implies :interactive false.
  --report-format     The report format: :text, :edn or :ignore
  --ignore-vars       A list of vars to ignore
  --paths             A list of paths to analyze (files and dirs)
  --out-dir           Emit transformed code to out-dir instead of overwriting
  --aggressive        Run carve multiple times to detect transitive unused vars
  --clj-kondo/config  A map of clj-kondo config opts that are passed on to clj-kondo
  --opts              The options as an EDN literal
  --api-namespaces    A list of namespaces to ignore
  --dry-run           Dry run
  --help              Display help
  --carve-ignore-file The file with ignored vars

πŸŒ™ 4
borkdude14:02:29

I'm looking into making a library compatible and this library has a data_readers.clj file. So far I haven't made babashka pick up on this automatically as this incurs a little bit of startup time (to scan the classpath for those files). I'm considering doing this lazily, when an (unknown) data reader is used for the first time...

Daniel Jomphe15:02:33

Data readers are quite tool-breaking, for sure (or tools aren't yet invested in being data readers compatible!). Not sure about all possible tradeoffs, but laziness might be great.

borkdude15:02:10

Yeah, I'm not a big fan of those, but they do exist

pesterhazy15:02:48

Can't think of a reason why laziness might cause problems

βž• 2
borkdude20:02:11

... and merged