This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-11
Channels
- # architecture (1)
- # babashka (61)
- # babashka-sci-dev (1)
- # beginners (85)
- # calva (112)
- # clj-kondo (279)
- # cljdoc (16)
- # cljs-dev (15)
- # cljsrn (7)
- # clojure (168)
- # clojure-europe (36)
- # clojure-nl (10)
- # clojure-spec (6)
- # clojure-uk (5)
- # clojured (1)
- # clojurescript (20)
- # core-async (16)
- # crypto (2)
- # cursive (13)
- # datomic (25)
- # events (7)
- # fulcro (21)
- # google-cloud (3)
- # graalvm (2)
- # graalvm-mobile (2)
- # gratitude (3)
- # helix (20)
- # honeysql (4)
- # hugsql (15)
- # introduce-yourself (15)
- # leiningen (2)
- # lsp (24)
- # luminus (22)
- # malli (21)
- # meander (11)
- # midje (1)
- # other-languages (1)
- # pathom (8)
- # re-frame (5)
- # reagent (5)
- # releases (2)
- # reveal (1)
- # shadow-cljs (18)
- # spacemacs (17)
- # sql (9)
- # tools-build (12)
- # tools-deps (4)
- # vim (12)
Hey, folks. Probably a dumb question but here goes:
How can I import a local file when using bb? Say file 1 is lox.clj
with (ns lox.core)
and file 2 is utils.clj
with (ns lox.utils)
? Located together in the same folder. How can I import lox.utils
to use functions defined in that namespace?
lein classpath > .classpath
bb -cp $(cat .classpath) -m "your main namespace"
Then you can have the following structure:
$project/bb.edn: {:paths ["."]}
$project/foo.clj: ...
$project/bar.clj: (require 'foo)
A lot of times you will put the sources under script
or src-bb
or whatever, then your bb.edn will look like {:paths ["src-bb"]}}
for example
@UTT4YNYNS can you try to make a .clj-kondo
director in the e1
directory and make sure you open VSCode also in that directory, then restart the editor and also make sure to edit a file
I thought this issue was about .clj-kondo. Different problem and different person :)
No worries! The fact that you're actively helping folks is insane and very kind. Where can I donate/support you and your efforts? One day I'd really like to help out with some open source work as well. Right now I'm just a super noob at clojure stuff so I don't have a ton of value to add.
^ Yes that is basically the problem I'm having. main.clj is the main thing, utils is some extra functions I moved to try and keep main clean. I just want to require utils and use functions from within it
I don't have any namespace forms atm. I removed them when I was trying random things to get it working
ok, you will need a namespace form that reflects the filename. in main.clj
you have to write (ns main)
- the same for utils.clj
-> (ns utils)
Do I have to move the require section to the namespace form in main? as in (ns main (:require ...))
?
Currently I have this and I'm still getting the "Could not resolve symbol" error.
(ns main)
(require '[clojure.string :as str]
'[utils :as u])
Hey. Is there lein
in this docker container? I can't find it.
https://github.com/babashka/babashka/blob/master/Dockerfile
It's written that it contains it in the FROM
image but it's not in the $PATH
.
No, its a multistage build and for the final one https://github.com/babashka/babashka/blob/master/Dockerfile#L73 we just have the bb binary in an ubuntu image
Yeaah... I figured it could be the case but then how do I get a bb
image with lein
...?
you need to extend your image using FROM babashka/babashka:0.7.4
or something
then install lein jvm etc
its by design that the bb image is as lean as possible.
But then why would I care to use that container and instead not install bb
and lein
from package manager from somewhere else... If I install java
I might as well be full author of the container... Hm.
either works. the idea here is bb is an orthogonal runtime to the JVM. if you need both you need to set it up that way. not sure if we'd wanna ship both bb and the JVM in an image, as most use cases of bb is not to use the JVM
Yes. That makes sense.
we did not have a need to ship the JVM too til now from the users, let us know if theres some strong requirement, we can think about it 🙂
I was trying to create an image for testing. So that developers would be able to download it and run some commands. That's pretty much it.
Right, i guess building it yourself and letting the container runtime cache it locally would work for most cases for now. But in some recent commits on bb i think @U06FS3DLH has a plan to have bb images as part of the clojure https://hub.docker.com/_/clojure we https://github.com/babashka/babashka/pull/1099 on some parts of it. maybe that has lein+bb? maybe he can confirm here?
Once your dependencies are in the images, you probably don't need lein in the image anymore. It's only for downloading dependencies but for running bb doesn't need a JVM or lein or deps.edn, etc. For startup time you want to avoid those basically.
This is my container:
FROM clojure:openjdk-11-lein-buster
#
RUN curl -sLO && chmod +x install && ./install
Yeah, if you need both, I think that's good / pragmatic. Installing bb is really fast.
Yeah I was kind of waiting to see if there was demand for that beyond the babashka/babashka
image. Sounds like maybe there is?
If it's two lines then it can be added to readme 😄
Yeah, I think the use case "I want control over my image otherwise, but I just want to run bb scripts too" is quite common!
https://clojurians.slack.com/archives/CLX41ASCS/p1618151064007300?thread_ts=1618130487.484500&cid=CLX41ASCS I see conditional dependencies have been discussed before. Was anything like this ever implemented?
All good, not a big deal.. just wanted to see if maybe it was missed in the docs. Thanks!
it appears babashka 0.7.4 is passing a string arg to one of my pods as ascii rather than utf8. it was how I was decoding it (`(String. bytes)` vs. (String bytes "UTF-8")
). or am I doing something wrong? I'm seeing ü
turn into ?
no, just what I'm testing w/ now. edn
might be how I'm decoding it on my end
going to try changing (String. bytes)
to (String. bytes "UTF-8")
in my pod and see what that does
it defaults to "platform charset" and this is running in an AWS lambda, so kind of an odd platform
yep, that fixed it. all on my end!