Fork me on GitHub
#clojurescript
<
2023-06-03
>
Fay Carsons16:06:38

Does anyone know how to properly require core.matrix in cljs? I have aljabr as a dependency, I’ve tried the different suggestions I’ve found on stack overflow etc, but I’m getting this error "No dynamic loading of implementations in Clojurescript. You must require an implementation explicitly in a namespace, for example thinktopic.aljabr.core"

p-himik16:06:27

What is your current code that results in that error?

p-himik16:06:46

For reference, see how the implementation is required in the test namespace (I assume their tests run just fine, I haven't actually checked): https://github.com/originrose/aljabr/blob/master/test/thinktopic/aljabr/test_all.cljc#L3-L6

Fay Carsons16:06:59

Currently requiring and calling it like this, still getting the above error.

Fay Carsons16:06:38

The error goes away if I take out the test-mat bit. using shadow.cljs if thats relevant?

p-himik16:06:26

Shadow-cljs shouldn't be relevant here. But that test NS is incomplete in the sense that it only uses mat/shape from the whole core.matrix API.

p-himik17:06:22

Try using (mat/matrix :aljabr [...]). Does it work?

Fay Carsons17:06:29

mat/matrix works without the keyword, the issue is seemingly only when I call mat/inverse on something.

Fay Carsons17:06:46

or, on a matrix, specifically

p-himik17:06:06

But does adding that keyword fix the error? Regardless of what expression resulted in the error.

Fay Carsons17:06:32

Adding the keyword to mat/inverse before the matrix throws an error, too many arguments

p-himik17:06:01

You need to add it to the matrix call.

p-himik17:06:09

Even if it's the inverse call that causes that error.

Fay Carsons17:06:33

I tried this (mat/inverse (mat/matrix :aljabr [[1 2][3 4]])) and got this error INFO: No dynamic loading of implementations in Clojurescript. You must require an implementation explicitly in a namespace, for example thinktopic.aljabr.core.

p-himik17:06:25

Is the only symptom just that error message? Or do things not work at all?

p-himik18:06:09

Instead of explicitly providing that keyword every time, you can also do (mat/set-current-implementation :aljabr), just like here: https://github.com/mikera/core.matrix/blob/develop/src/test/cljs/clojure/core/matrix/test_basics.cljs#LL19C41-L19C41 Judging by the implementation, it will still result in that error. But it's a false symptom because the error is printed unconditionally.