Fork me on GitHub
#beginners
<
2021-05-08
>
Ale06:05:32

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?

pez07:05:29

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

Ale07:05:04

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

(do (require '[clojure.edn :as edn] 
         '[ :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

Ale08:05:10

@U0ETXRFEW 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.

pez08:05:08

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

Ale08:05:43

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

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

pez08:05:37

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

Ale08:05:31

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

pez08:05:29

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

Ale08:05:21

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

Ale09:05:46

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)

Ale09:05:09

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

pez09:05:53

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

pez09:05:24

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

pez09:05:31

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

Ale09:05:48

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

Ale09:05:54

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)

pez09:05:39

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

Ale09:05:52

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

pez09:05:14

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.

Ale09:05:53

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

pez09:05:50

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

pez10:05:55

No problems using 822 of clojure.

Ale10:05:32

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

clj꞉user꞉>  ; 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

pez10:05:43

I thought it would. Now we know.

Ale10:05:15

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

pez10:05:19

No problems with Java8 here.

pez10:05:37

Android works to, I tried by mistake. 😃

pez10:05:21

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.

Ale10:05:55

what version are you on?

pez10:05:07

14 something. let me check…

pez10:05:31

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

pez10:05:33

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

pez10:05:42

alt+enter

pez10:05:18

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

Ale11:05:21

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

Ale11:05:43

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

Ale12:05:15

@U0ETXRFEW 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.

pez12:05:53

Is the app running in the simulator?

pez12:05:56

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

Ale12:05:00

Yes, in the simulator

Ale12:05:15

I still haven't tried on my phone

pez13:05:43

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

Ale13:05:19

ahah I see ^^

Ale13:05:36

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

Ale13:05:01

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 @.@

Ale13:05:24

;_; still no way out

pez14:05:11

Tried cleaning away .cpcache and target?

Ale14:05:21

i hadn't thought of cpcache! let me try

Ale14:05:01

no luck 😞

pez14:05:20

Do you get a stacktrace somewhere?

Ale14:05:40

yes, in the cider debugger

Ale14:05:44

this one

pez14:05:18

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

Ale14:05:11

Thanks, will do ^^

Ale14:05:23

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 => prompt and can for example open an alert window on the app, but I get other errors in the repl (cljs.pprint.pprint related).

Ale14:05:40

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

pez14:05:50

Yes, please do.

Ale15:05:12

Done, thanks 🙂

pez15:05:33

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

Ale15:05:06

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

Ale16:05:15

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)

Ale16:05:39

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

Ale16:05:58

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

Ale17:05:26

@U0ETXRFEW 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.

pez17:05:01

Ah, thanks for updating.

Ale04:05:46

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

pez08:05:38

@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.

Dave Suico14:05:16

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?

R.A. Porter14:05:59

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.

❤️ 3
pez14:05:35

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.

Oliver17:05:57

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

seancorfield17:05:38

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

seancorfield17:05:21

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

👍 3
Oliver17:05:06

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

hiredman18:05:26

It is a cljs thing

hiredman18:05:17

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

hiredman18:05:14

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

👍 6
Hagenek18:05:45

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?

Hagenek18:05:05

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?

GGfpc19:05:16

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