calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
grumplet 2021-01-30T00:05:13.353300Z

I’d like to automate cljs/figwheel-main/webpack a little better using deps. 1. Using a fig alias I can jack-in with Figwheel Main and compile. 2. With another alias I can then start a figwheel main repl that is connected to the editor. Between (1) and (2) I want to run webpack at least once. It looks like I can get access at this point by adding a :post-build-hooks vector in figwheel-main.edn. I feel it should be possible to supply a clojure function there which shells out to call webpack.

grumplet 2021-01-30T00:15:36.359Z

:post-build-hooks wants a namespaced function to call. However I can’t get this to resolve correctly - e.g. if I give it [user/foo] it can’t resolve namespace user. It would be simple if I understood how the classpath was defined when the :post-build-hooks functions are resolved. This might be a figwheel-main issue, but it may also be a Calva defined classpath. Does anybody have an idea how to put functions on the classpath at that point?

grumplet 2021-01-30T00:33:18.360900Z

OK - answering my own question - I guess the classpath there is the one built by Calva Jack-in which is echoed in the terminal.

grumplet 2021-01-30T00:34:18.361300Z

Now is there a way to add source paths to that?

pez 2021-01-30T08:54:51.365200Z

Calva does not build any classpaths. That will be done by Leiningen or the clojure CLI tool, depending on which one you use. If you define a profile (lein) or an alias (clj) then you can select these at Calva Jack-in and the command line will be built such that it invokes the profile/alias. I tried to explain the Jack-in feature a bit here: https://calva.io/jack-in-guide/

grumplet 2021-02-01T10:14:37.037400Z

Thanks@pez, Stupidly I’d tried that earlier but with source-paths rather than extra-paths. With extra-paths It no longer barfs about the user namespace, but I’m not seeing the println anywhere. And fair point - my fig alias is now misnamed as its :main-opts moved elsewhere.

pez 2021-02-01T11:20:09.038500Z

You’re welcome. I’m glad I got to try that out and learn a bit about these settings. As for the printout. Don’t recall where I found them. Maybe in the Jack-in terminal? Maybe in the (wrongly named) Output channel Calva Connection Log

grumplet 2021-02-02T10:10:20.071Z

Don’t spend time on this - but I tried all those. No errors, but nothing in any log as far as I can see.

pez 2021-02-02T10:21:35.071200Z

Haha, try to stop me. 😃 But not right now, working for food time.

grumplet 2021-02-04T18:25:02.142300Z

Just picked up on this again when I saw that missing Hello World suddenly appear at startup. So the println is working now and outputting to the REPL buffer after the build as it should. 🙂

grumplet 2021-02-04T18:25:53.142500Z

When I get some time I’ll see if I can get it to do something sensible with the npx webpack call.

1
Eric Uitbeijerse 2021-01-30T09:26:05.369Z

Hi all, I joined this channel about 2 wks ago and I must say that I'm very impressed by how active and responsive this community is. Already 2 of my issues fixed and I love Calva (and the extensions it uses). You are professionals and make me very happy! 😄 Kudos to all of you!🙌🙏:thumbsup:

5
❤️ 4
pez 2021-01-30T09:33:01.372600Z

Wow, @eric.uitbeijerse It is a pleasure to try to contribute to Clojure success, because the community is so welcoming, helpful, and interested in helping each other succeed. It makes me happy to hear that we Calva peeps are following the example. Thanks for sharing that!

grumplet 2021-01-30T10:30:53.372700Z

Sorry - I was thinking out loud there. Yes I agree, but Calva does build the CLI command line and passes it dependencies to go on the classpath using clojure -Sdeps. Maybe this output will clarify the problem I’m trying to solve - I can’t see how to get ‘user’ on the classpath. I have :post-build-hooks [user/foo]in figwheel-main.edn. user/foo is a placeholder for a function that will run webpack. I see this:

> Executing task: clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.2"} cider/cider-nrepl {:mvn/version "0.23.0"} clj-kondo {:mvn/version "2020.04.05"} cider/piggieback {:mvn/version "0.4.2"}}}' -A:fig:dev <
...

WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
2021-01-30 00:21:41.178:INFO::main: Logging initialized @3750ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel:WARNING] Compile Exception: Could not locate user__init.class, user.clj or user.cljc on classpath.  
post-build-hook-fn: There was an exception while requiring the namespace 'user while trying to load the var 'user/foo

grumplet 2021-01-30T10:38:18.373100Z

There’s probably a simpler way to tackle this 🙂

pez 2021-01-30T11:34:50.373300Z

I’m not sure I am following. But I get this to work. 1. Create a directory env as a sibling to src 2. Put a file user.clj there with (ns user) and (defn foo [arg] (println "Hello world, args: " arg)) 3. Add "env" to :extra-paths of the alias I am using 4. Add user/foo to :post-build-hooks

pez 2021-01-30T11:37:46.373500Z

I also see that you are using the alias :fig which I think often contains :main-opts . If so that will not chime with jack-in, unless those opts start the nrepl server. Try without selecting that alias. (Even if this should be unrelated to the problem with finding user/foo.)

2021-01-30T18:22:42.381400Z

Just reported two printing related issues. It would be nice to get them fixed. 🙏

Hagenek 2021-01-30T20:11:16.381800Z

Quick question for Vs code and Calva users. How do you stop evaluating when your functions enters an infinite loop?

clyfe 2021-01-30T20:12:29.382300Z

What OS you on?

Hagenek 2021-01-30T20:12:38.382700Z

Windows

Hagenek 2021-01-30T20:12:58.383300Z

https://app.slack.com/team/USMLDU9BR  [9:07 PM] Tried Ctrl-Alt-C Ctrl-Alt-D, but that does not seem to do the trick. (Should stop evaluations). (edited)

pez 2021-01-30T20:13:03.383600Z

There's a command for that. Iirc somethng like Interrupt running evaluation

clyfe 2021-01-30T20:13:32.383700Z

How about: Ctrl+Shift+P -> Calva: Interrupt Running Evaluations ?

clyfe 2021-01-30T20:14:25.383900Z

(I'm on Ubuntu/Gnome & Ctrl+Alt+D is show desktop)

Hagenek 2021-01-30T20:14:37.384100Z

It might be that there is a sluggishness in the system, that it actually interrupts it but text keeps coming into the REPL

Hagenek 2021-01-30T20:14:48.384300Z

I will stop it and wait and see if it stops coming text in the REPL after a while

pez 2021-01-30T20:18:46.386400Z

Yes, sluggishness. If you are printing from that loop that will not stop until the print queue use empty.

clyfe 2021-01-30T20:33:01.396400Z

I need a good story for customization; can't do well w/o my nitty gritty keyboard behaviors. a) I'm thinking: Calva to expose pretty much all it can (mirrored doc map, paredit fns, etc) in it's public API. That's the way to allow people to customize to their workflows. We can tag: "API subject to change" and things can break from time to time. That RH "never break API" is not the mother lode of good things, there are cases like here. b) Maintain a series of patches applied on releases from time to time. c) A setting flag "Calva: Natural mode" (killSpace, backspaceNoFormat) but the rabbit hole may be deep here.

clyfe 2021-01-30T20:33:53.396800Z

Probably a) with a well thought API is a good plan.

bringe 2021-01-30T22:24:53.397100Z

This sounds like this issue: https://github.com/BetterThanTomorrow/calva/issues/978