This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-15
Channels
- # announcements (11)
- # aws (5)
- # babashka (69)
- # beginners (138)
- # calva (5)
- # cider (11)
- # cljsrn (3)
- # clojure (86)
- # clojure-europe (8)
- # clojure-italy (2)
- # clojure-nl (5)
- # clojure-norway (13)
- # clojure-uk (21)
- # clojurescript (13)
- # conjure (58)
- # core-typed (2)
- # data-science (2)
- # datomic (5)
- # degree9 (4)
- # emotion-cljs (4)
- # figwheel-main (8)
- # fulcro (29)
- # graalvm (70)
- # interop (2)
- # joker (1)
- # lein-figwheel (2)
- # leiningen (13)
- # liberator (4)
- # off-topic (21)
- # pedestal (2)
- # re-frame (10)
- # shadow-cljs (42)
- # spacemacs (29)
- # spire (1)
- # tools-deps (11)
- # vim (26)
- # xtdb (5)
Is it possible to create tab-completion with a graalvm compiled project? Like the video below? If so, can someone point me at the right direction?
It’s os/shell like https://iridakos.com/programming/2018/03/01/bash-programmable-completion-tutorial
@kevin.van.rooijen https://github.com/l3nz/cli-matic/issues/39 might be of interest to you as well. If you want to go further into the direction of generating the completion from an abstract option declaration, I can recommend https://github.com/spf13/cobra/blob/master/bash_completions.go as reference.
Added clj-http to my project and getting this error:
Error: No instances of javax.net.ssl.SSLContext are allowed in the image heap as this class should be initialized at image runtime. Object has been initialized without the native-image initialization instrumentation and the stack trace can't be tracked.
Tried setting this flag --initialize-at-run-time=.ssl.SSLContext
and other things but can't seem to get anything going.Seems like the graalvm-clojure project struck out of luck as well https://github.com/BrunoBonacci/graalvm-clojure/tree/master/http-kit#notes-on-http-kit-client
@naomarik isnt't this just these flags?
"-H:EnableURLProtocols=http,https"
"--enable-all-security-services"
apparently not: https://github.com/oracle/graal/issues/1074
yeah was about to post that https://github.com/oracle/graal/issues/1074
I'm playing around with attaching a debugger but I have no idea what I'm doing... seeing if I can get a breakpoint somewhere
if you can figure that one out, it would be great. clj-http-lite has been the escape hatch for it for a while
yeah it works for me, but I tend to get stubborn with issues and it's hard to not dig myself in a hole until I get things working the way I want
Not sure how to do this, in clojure top level require seems to initialize classes which cascades all the way down to the java SSL stuff and trying to wrap http client in a function to dynamically require gets it compiled out of graalvm.
@naomarik you can't dynamically require something in a graalvm image, at runtime. it has to required at compile time
I hacked clj-http wrapping the problematic code in a delay and it works, passes all tests too.
I mean, can you do everything that's done in the units tests, with your graalvm binary? that remains to be seen right?
@naomarik one way of testing this is to bind the clj-http functions into babashka and then run the tests using babashka
sure: 1) create one of those and hook it up in babashka/main.clj: https://github.com/borkdude/babashka/blob/master/feature-yaml/babashka/impl/yaml.clj 2) copy the library tests to https://github.com/borkdude/babashka/tree/master/test-resources/lib_tests/clj_yaml 3) run all tests within the bb binary: https://github.com/borkdude/babashka/blob/master/script/lib_tests/clj_yaml_test
Here's a patch: https://pastebin.com/raw/d5CCRK9z
here are some hints how to get started. most often people don't clone recursively: https://github.com/borkdude/babashka/blob/master/doc/dev.md
Hey @borkdude, I copied https://github.com/dakrone/clj-http/blob/3.x/test/clj_http/test/core_test.clj into test-resources/lib_tests
like like clj-yaml.core-test
, I edited babashka.impl.clj-http
and main.clj
get rid of each error as it came up and got around here:
➜ lib_tests git:(master) ✗ ./clj_http_test
java.lang.Exception: Could not require ring.adapter.jetty. [at /home/naomarik/babashka/test-resources/lib_tests/clj_http/core_test.clj, line 1, column 1]
Error encountered performing task 'run' with profile(s): 'test'
Suppressed exit
➜ lib_tests git:(master) ✗ ./clj_http_test
java.lang.Exception: Unable to resolve classname: java.net.SocketTimeoutException [at /home/naomarik/babashka/test-resources/lib_tests/clj_http/core_test.clj, line 1, column 1]
Error encountered performing task 'run' with profile(s): 'test'
Suppressed exit
before giving up, there's an enormous amount of imports and not sure whether I was putting the right code in the impl file.@naomarik I see: the clj-http tests run a server to test clj-http. this requires a bit of a different approach. the server needs to be started in a JVM, and then the clj-http test code needs to run in babashka itself
yeah seems like a long story 🙂 can't spend time on it anymore unfortunately, but running around babashka source, man you've done a lot of work!
@naomarik you can try to do a couple of request just outside the tests though: bb -e "(require '[clj-http ...] (client/get ...)"
, etc
@naomarik I also tried it locally myself now with your fork.
$ ./bb "(require '[clj-http.client :as client]) (:status (client/get \"\"))"
java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl [at line 1, column 50]
adds about 40MBs to the bb binary (100 mb in total) and eats a lot more ram (if I give it 8GB, it will eat 8GB)saw a similar thing with hato. clj-http-lite might be a nice middle ground for native-image CLIs
or if shelling out to curl is fine, then https://github.com/borkdude/babashka.curl is probably the lightest solution
Using GRAALVM_VERSION="20.1.0" , openjdk version "11.0.7" 2020-04-14 under WSL2 ubuntu
These are binaries built on CI:
[8:02 PM] [linux-static - dakrone-clj-http@bfffbd9400c04e3c345f2251b4ab8a4fa68a7d19]:
[8:02 PM] [linux-static - dakrone-clj-http@bfffbd9400c04e3c345f2251b4ab8a4fa68a7d19] binary size: 105772312
[8:03 PM] [linux - dakrone-clj-http@bfffbd9400c04e3c345f2251b4ab8a4fa68a7d19]:
[8:03 PM] [linux - dakrone-clj-http@bfffbd9400c04e3c345f2251b4ab8a4fa68a7d19] binary size: 110654720
[8:05 PM] [macos - dakrone-clj-http@bfffbd9400c04e3c345f2251b4ab8a4fa68a7d19]:
[8:05 PM] [macos - dakrone-clj-http@bfffbd9400c04e3c345f2251b4ab8a4fa68a7d19] binary size: 103977664