beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
Edward Ciafardini 2021-05-08T01:14:44.375400Z

thank you for all you do

Ale 2021-05-08T06:29:32.383Z

Hello, I'm trying out cljs+krell for react native development. I could finally run a simple app after some troubleshooting, and I can successfully run the repl from the command line (using the clj cli tool), but when I try to run the krell repl from cider I get this error:

Execution error (ExceptionInfo) at cljs.repl/evaluate-form (repl.cljc:577).
ReferenceError: Can't find variable: cljs
Does anyone have a clue about this error?

pez 2021-05-08T07:51:29.384900Z

@laynor cider has a jack-in option for Krell. Is that what you are using?

Ale 2021-05-09T17:23:26.435100Z

@pez just to let you know, I finally opened an issue on krell's github - I tried some old versions and finally I got one of them working (last commit Feb 25) - it appears the issue is triggered by some relatively recent changes in krell itself.

pez 2021-05-09T17:42:01.435700Z

Ah, thanks for updating.

Ale 2021-05-10T04:38:46.454200Z

you are welcome, thanks for all the help ^_^

Ale 2021-05-08T07:55:04.385Z

Yes, that's right. I also tried with the "custom" jack in option and inserting

(do (require '[clojure.edn :as edn] 
         '[<http://clojure.java.io|clojure.java.io> :as io]
         '[cider.piggieback] 
         '[krell.api :as krell]
         '[krell.repl])

    (def config (edn/read-string (slurp (io/file "build.edn"))))
    (krell/build config)
    (apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config)))
when prompted for a form to start the repl

Ale 2021-05-08T08:04:10.385200Z

@pez I can provide more detailed information - stack trace, edn files or even just push the whole thing on github if that is useful to understand the issue. It's just the hello krell app anyway.

pez 2021-05-08T08:12:08.385400Z

I’m not a Cider user myself, but I use the same infrastructure (cider-nrepl, piggieback) and I could get the hello krell thing to work the other day. Maybe something has happened with Krell… I saw your questions and solution in the #cljsrn channel… Can you try with this sha for the Krell dep? c487f7c3a8ce1b3d74757d5a0af2a776f7704d94

pez 2021-05-08T08:18:38.388600Z

@qmstuart evaluating (run-tests) should work. And as @emilaasa suggests, using Calva custom REPL commands for it can sweeten up the workflow. But first the evaluation must work of course… If you can create a minimal repro project that we can clone, I can give it a spin and see what I can figure out.

Ale 2021-05-08T08:34:43.388700Z

@pez Still having the same issue 😞 This is my deps.edn file:

{:deps {io.vouch/krell {:git/url "<https://github.com/vouch-opensource/krell.git>"
                        ;; :sha "a6bf860df2385384b36dea68bcf2e3163a14bfa8"}
                        :sha "c487f7c3a8ce1b3d74757d5a0af2a776f7704d94"}
        io.vouch/reagent-react-native {:git/url "<https://github.com/vouch-opensource/reagent-react-native.git>"
                                       :sha "0fe1c600c9b81180f76b94ef6004c2f85e7d4aa0"}
        reagent/reagent {:mvn/version "1.0.0"
                         :exclusions [cljsjs/react cljsjs/react-dom]}}}

pez 2021-05-08T08:37:37.388900Z

I see only two differences from mine. 1. I’m using this sha for reagent-react-native0fe1c600c9b81180f76b94ef6004c2f85e7d4aa0` 2. I’m using reagent 0.10.0

Ale 2021-05-08T08:39:31.389100Z

isn't the reagent-react-native sha the same?

pez 2021-05-08T08:40:29.389300Z

oh, yes, I missread. So then only reagent.

Ale 2021-05-08T08:46:21.389500Z

tried changing reagent version but nothing changed 😕 this is the full exception stack trace: https://gist.github.com/laynor/c6b0a85d200560f359cf007f6d04fef3

Ale 2021-05-08T09:05:46.389800Z

I actually also tried to get your example running https://github.com/PEZ/awesome-krell-project but I'm running into other issues (NPE when starting the repl from the command line, same issue as my project from cider)

Ale 2021-05-08T09:09:09.390100Z

Also, when I run the app on the android emulator, it stays stuck in the "Waiting for krell to load files" screen

pez 2021-05-08T09:16:53.391600Z

Oh, that is a pretty old project. I'll update it. Good with the reminder.

pez 2021-05-08T09:17:24.392300Z

Publish your project and I'll give it a spin.

Ale 2021-05-08T09:31:37.392500Z

ok thanks! here it is https://github.com/laynor/krelltest

pez 2021-05-08T09:47:31.392800Z

So, no problems at all jacking in from Calva. What system/java/etcetera are you using?

Ale 2021-05-08T09:50:48.393Z

Hey thanks for giving it a go! My system details: Os: Arch linux Emacs: recent version compiled from sources (master). native comp enabled Cider version: "CIDER 1.1.0 (package: 20210422.802) (Plovdiv)" clojure --version: Clojure CLI version 1.10.3.822

Ale 2021-05-08T09:51:54.393200Z

Output of java --version

θ60° [ale:~/src/krelltest] master(+7364/-6020) ± java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)

pez 2021-05-08T09:52:39.393400Z

So, a bit newer Clojure CLI than I have (814). Let me see which java I use …

Ale 2021-05-08T09:52:52.393600Z

don't know if it's relevant, Nodejs version v16.1.0

pez 2021-05-08T09:55:14.393800Z

Very hard to know what’s relevant. 😃 I use Java15 at the moment. Will try with Java 8. But first will try with latest clojure CLI.

Ale 2021-05-08T09:55:53.394Z

I think java 15 doesn't work for android, that's the reason I'm using an older version 😞

pez 2021-05-08T09:58:50.394200Z

You can try with Calva, so we can rule out that it is a CIDER problem.

pez 2021-05-08T09:59:03.394400Z

https://calva.io/krell/

pez 2021-05-08T10:01:55.394700Z

No problems using 822 of clojure.

Ale 2021-05-08T10:07:32.394900Z

It seems I'm getting the same error with Calva: the repl shows this

clj꞉user꞉&gt;  ; Use `alt+enter` to evaluate
; Creating cljs repl session...
; Connecting cljs repl: deps.edn + Krell...
;   The Calva Connection Log might have more connection progress information.
; Execution error (ExceptionInfo) at cljs.repl/evaluate-form (repl.cljc:577).
ReferenceError: Can't find variable: cljs

pez 2021-05-08T10:08:43.395200Z

I thought it would. Now we know.

Ale 2021-05-08T10:09:15.395400Z

(by the way, what keybinding did you use to send the current form to the repl when you recorded?)

pez 2021-05-08T10:09:19.395600Z

No problems with Java8 here.

pez 2021-05-08T10:09:37.395800Z

Android works to, I tried by mistake. 😃

Ale 2021-05-08T10:09:56.396Z

😄

pez 2021-05-08T10:11:21.396200Z

I have no easy way to try with newer nodejs. I depend on node a bit too heavily to dare. But I seriously also doubt that is the problem here.

Ale 2021-05-08T10:11:55.396400Z

what version are you on?

pez 2021-05-08T10:12:07.396600Z

14 something. let me check…

pez 2021-05-08T10:12:31.396800Z

~/Projects/tests/krelltest(master|✚2…) % node --version
v14.3.0

pez 2021-05-08T10:13:33.397Z

> (by the way, what keybinding did you use to send the current form to the repl when you recorded?)

pez 2021-05-08T10:13:42.397200Z

alt+enter

pez 2021-05-08T10:14:18.397400Z

Run the command Fire up the Getting Started REPL to get a short primer on evaluating stuff in Calva. 😃

Ale 2021-05-08T11:42:21.397600Z

I'll try with your node version to see if sometihng changes ^^ Calva looks slick but switching from emacs is very very painful for me ahah

Ale 2021-05-08T11:42:43.397800Z

Will let you know how it goes, thanks for all the help so far!

Ale 2021-05-08T12:36:15.398Z

@pez It's working on emacs/cider with your node version!! 🥳 The other difference is that this node is installed in my home, while the former one was the system one - this might make a difference if some script tries to install something globally I guess. Strange thing - the calva repl hangs waiting the cljs repl for some reason (it stays stuck at the java repl). Don't know what's wrong - I tried switching clj/cljs from the command palette but I may just have done something wrong.

pez 2021-05-08T12:49:53.398900Z

Is the app running in the simulator?

pez 2021-05-08T12:50:56.399700Z

I don't think anything is installed globally by any script.

Ale 2021-05-08T12:55:00.399900Z

Yes, in the simulator

Ale 2021-05-08T12:55:15.400100Z

I still haven't tried on my phone

pez 2021-05-08T13:09:43.401Z

It was running that I was curious about*.* 😎

Ale 2021-05-08T13:13:19.401200Z

ahah I see ^^

Ale 2021-05-08T13:13:36.401400Z

the app was running at the beginning too - but no luck with cider

Ale 2021-05-08T13:17:01.401600Z

btw, I wanted to understand about the node thing - so I installed v16.1.0 with nvm and got the same issue as before. So I went back to v14.3.0, but now I got the bug on v14.3.0 too @.@

Ale 2021-05-08T13:47:24.401800Z

;_; still no way out

Dave Suico 2021-05-08T14:03:16.404200Z

Hi guys I'm using VS Code and Calva and I have this task where I need to get a value from my win 10 environment using System/getenv, it works in first try but when I updated the value and then call getenv again it doesn't return the updated value. Is there anyway I could get the new value without having to restart my PC?

pez 2021-05-08T14:04:11.405100Z

Tried cleaning away .cpcache and target?

Ale 2021-05-08T14:05:21.405300Z

i hadn't thought of cpcache! let me try

Ale 2021-05-08T14:14:01.405500Z

no luck 😞

pez 2021-05-08T14:31:20.406500Z

Do you get a stacktrace somewhere?

Ale 2021-05-08T14:37:40.410800Z

yes, in the cider debugger

pez 2021-05-08T14:38:35.412100Z

You can't set the environment of a child process when it is started. I think only Plan 9 supports that. But neither should a system restart be necessary. Restarting the REPL from where you have changed the environment variable is enough. If you are using Calva Jack-in you can use the jackInEnv setting and then just jack-in again, which will restart the REPL with the variables you have set in the setting.

Ale 2021-05-08T14:38:44.412400Z

this one

R.A. Porter 2021-05-08T14:38:59.412600Z

System variables are set in the shell when it starts; the process reads those. If you want the Clojure process to reflect an updated environment variable, you need to call System/setenv in the same process.

1❤️
pez 2021-05-08T14:41:18.414Z

Post about this in the #nrepl channel. Maybe someone there has a clue given what we have tested and that stacktrace.

Ale 2021-05-08T14:45:11.414200Z

Thanks, will do ^^

Ale 2021-05-08T14:51:23.414400Z

strangest stuff - I have a copy of the same project (after I pushed, i recloned the repo I shared with you to test it before giving you the url) and if I run npx react-native start and npx react-native run-android in the newer clone, but then jack in from the old project, I get a half working repl (I reach the cljs.user =&gt; prompt and can for example open an alert window on the app, but I get other errors in the repl (cljs.pprint.pprint related).

Ale 2021-05-08T14:56:40.414600Z

Is it fine if I mention you to say the project works at least on your machine?

pez 2021-05-08T14:59:50.415100Z

Yes, please do.

Ale 2021-05-08T15:24:12.415300Z

Done, thanks 🙂

pez 2021-05-08T15:47:33.416Z

Do you have better luck with shadow-cljs, maybe? Could be worth a try, unless you have specific reasons to use Krell.

Ale 2021-05-08T15:59:06.416300Z

I had success only with shadow-cljs + expo (with your template ahaha)

Ale 2021-05-08T16:00:15.416500Z

but I often had to clear the expo app data and restart things due to some weird errors (that now I can't really remember well)

Ale 2021-05-08T16:00:39.416700Z

having so many layers disturbs me a bit because the amount of things that I don't understand increases

Ale 2021-05-08T16:01:58.416900Z

before trying krell I tried setting up a shadow-cljs + reagent project but can't really remember what went wrong

Oliver 2021-05-08T17:33:57.418400Z

What does this ^:keyword notation mean, eg. (defn ^:export init ...)?

seancorfield 2021-05-08T17:35:38.419400Z

@oliver.heck That is shorthand for ^{:export true} which is metadata added to the symbol (or more generally expression) that follows it.

seancorfield 2021-05-08T17:36:21.419700Z

See https://clojure.org/reference/metadata#_metadata_reader_macros specifically (but that whole page in general)

1👍
Oliver 2021-05-08T17:40:06.420400Z

So this is probably some hint to the compiler? :thinking_face:

2021-05-08T18:13:26.420500Z

It is a cljs thing

2021-05-08T18:14:17.420600Z

The assumption in cljs is that you will be passing the output through the google closure compiler, with will mangle all the names

2021-05-08T18:15:14.420700Z

Marking for export let's google closure know you want to be able to refer to that name from some external code

2👍
Hagenek 2021-05-08T18:17:45.422900Z

Hi. I am currently going through Web development in clojure and learning Luminus. I want to migrate my H2 db to add a column. The problem: Since I had SQL Exception, I get the "Migration reserved by another instance" message. What would be your quickest way to edit the schema_migrations table in my database, like it says here? https://clojure.tgenedavis.com/2020-10-01/clojure-migratus-migration-reserved-by-another-instance/ Should I get the H2 Console app or is it an easier way?

Hagenek 2021-05-08T18:43:05.423Z

Got the http://db.mv file opened in DbVisualizer, found the schema_migration table but there is no row that has id of -1 and Drop table is a pro feature.. EDIT: Managed to drop the migration table with a script.. seems like I fixed the issue. I would never do this in production or anything, seems like a pretty nasty bug?

GGfpc 2021-05-08T19:39:19.423800Z

Has anyone here used this library? https://github.com/alaisi/postgres.async

GGfpc 2021-05-08T19:45:16.424500Z

Alternatively, can anyone suggest a library to work with PostgreSQL asynchronously?