This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-27
Channels
- # announcements (24)
- # babashka (26)
- # beginners (8)
- # calva (8)
- # clojure (78)
- # clojure-europe (1)
- # clojure-norway (22)
- # clojurescript (14)
- # datascript (5)
- # datomic (8)
- # fulcro (22)
- # helix (9)
- # humbleui (11)
- # malli (4)
- # off-topic (28)
- # pedestal (5)
- # reitit (10)
- # shadow-cljs (2)
- # tools-build (8)
- # tools-deps (9)
Is there a crossplatform way to copy something to clipboard?
If you search this channel for "clipboard" you will find some options
clipboard in:#babashka
Ok not so easy then. I’ll work around it.
tl;dr: Prompting for passwords from a Babashka script, anyone?
I am developing a Babashka script, and I want it to run a shell command (specifically cryptsetup luksOpen
) which prompts for a password.
Of course, I do not want the script to echo the password in plaintext when the user enters it.
How to get the password from the user?
(I already tried asking ChatGPT but it hallucinated on it and gave me answers which did not work.)
You could use gum input --password
via https://github.com/lispyclouds/bblgum
if the program prompts for a password, then have the program inherit stdin should using the program's masking mechanism
This normally works too: https://github.com/babashka/babashka/issues/1632 but was broken in a recent GraalVM version that bb started using
It's fixed now so when I will upgrade to the next GraalVM version, it will work again. I'll do so before the next release. For now you can use an older release, perhaps
@U04V15CAJ,
Thanks for your reply.
I have upgraded Babashka from version 1.3.186 to version 1.3.188.
When trying to (.readPassword (System/console))
(and also when trying to run the script in the aforementioned issue 1632), I get the error:
java.lang.UnsatisfiedLinkError: jdk.internal.io.JdkConsoleImpl.echo(Z)Z [symbol: Java_jdk_internal_io_JdkConsoleImpl_echo or Java_jdk_internal_io_JdkConsoleImpl_echo__Z] [at <repl>:31:1]
What can I do today besides waiting for a working GraalVM version? Can I upgrade it today?I've pushed a branch now with the GraalVM upgrade, you can download a test build later, I'll post a link
I can confirm locally that 21.0.2 fixes it: $ ./bb -e '(.readPassword (System/console))'
My OS is Linux Debian 11 ("Debian Bullseye"). I also have Java 17 (`java-17-openjdk-amd64` to be precise).
Java version doesn't matter. Please try this version, it should work: https://38182-201467090-gh.circle-artifacts.com/0/release/babashka-1.3.189-SNAPSHOT-linux-amd64-static.tar.gz
When trying to download it, my browser tells me that the site cannot be reached ("Check if there is a typo in http://38182-201467090-gh.circle-artifacts.com"). I also tried curl -o -L (like in the babashka-install script), and it too complained about the unreachable hostname.
this should be the correct link: https://output.circle-artifacts.com/output/job/ff1e6b50-6dd5-471d-959e-2b380661e5c9/artifacts/0/release/babashka-1.3.189-SNAPSHOT-linux-amd64-static.tar.gz
The next hurdle is that with babashka-1.3.189-SNAPSHOT, str does not know how to deal with the returned password data:
user=> (.readPassword (System/console))
;; (I enter 'a'. I see a single asterisk. Then I hit ENTER)
#object["[C" 0x22355512 "[C@22355512"]
When I try (str (.readPassword (System/console)))
I see "[C@b490d39"
(The actual numbers change each time, they seem to be related to memory addresses.)It's a byte array, you can convert it to string with (String. the-bye-array "utf-8")
user==> (String. (.readPassword (System/console)) "utf-8")
;; (I entered 'a' followed by ENTER and saw a single asterisk)
No matching ctor found for class java.lang.String
Did I miss any require
or use
? 🙁
Or should I somehow convert the "utf-8" string into a Charset instance?(String. (.readPassword (System/console)))
;; (I entered text followed by ENTER. I saw asterisks. Guess which text :-)
"By golly, it works!"
@U04V15CAJ, Thanks for fixing the problem and for helping me make use of the fix. Approximately how long until the fix is officially released as a new Babashka version? (not urgent for me, just to satisfy my curiosity)