Fork me on GitHub
#babashka
<
2023-01-02
>
hugod15:01:25

I’m running a clojure.test test with bb, and getting a failure which is a sci exception. I am not understanding what the exception is being caused by. Any hints? https://gist.github.com/hugoduncan/dbd05c7a1cba78651a81d43bc4dd9a64

borkdude15:01:28

Happy new year! Great to see you back here. Caused by: java.lang.NoSuchFieldException: ns This error is usually caused by some lower level code which tries to print a namespace as a symbol, which you can nowadays just do using (symbol *ns*) instead of (.ns whatever)

borkdude15:01:12

Oh, I think this is because someone is trying to get the namespace from a var

hugod15:01:18

Happy new year to you too!

hugod15:01:20

ok, the “ns” exception message from sci was causing me to wonder if this was some sort of sci internal issue

borkdude15:01:02

could be, but I've seen this error message often enough by now :)

borkdude15:01:36

I guess Clojure doesn't have a nice way to get the namespace from a var without using Java interop

borkdude15:01:17

To make code SCI compatible I usually go through the metadata instead

hugod15:01:33

I’m interning vars for *compile-path* and `*compiler-options*`, which could be part of the issue

hugod15:01:30

Could sci indicate the location of the offending code?

borkdude15:01:23

In some cases it can... is it possible to make a clojure.test repro with this pretty bad internal stack trace leaking out?

hugod15:01:48

I’m trying to update tools.bbuild to latest tolos.build, so I could PR that - would that be ok as a repro?

hugod16:01:08

it’s on the update-to-tools-build-0.9.0 branch of tools.bbuild. You’ll need the PR version of tools-deps-native.

hugod16:01:41

I’m running bb test from tools.bbuild

borkdude16:01:15

does it even build for you locally?

borkdude16:01:24

I mean, the PR is failing right?

hugod16:01:14

oh, maybe I made a mistake cleaning up. let me check.

borkdude16:01:33

the linux PR is failing for a different unrelated reason I think it can be fixed by copying this file to the repo: https://github.com/babashka/babashka/blob/master/script/setup-musl

borkdude16:01:32

It looks like an http client is used somewhere on the top level maybe?

borkdude16:01:38

Perhaps upgrading graalvm helps btw

hugod16:01:55

I’m using 22.3 - just pushed ci changes for the same

borkdude16:01:01

ok. perhaps the error is related to the s3 client, e.g. https://github.com/clojure/tools.deps.alpha/commit/f97452b478775796967baa17b2d5b9a5f660556e The changes over the past year, introduced quite some requiring-resolve which is terrible with graalvm native image

borkdude16:01:12

I think it's safest to update tools deps alpha to a version which is closer to the one before (or git/sha) so we can detect better where problems are coming from

hugod17:01:28

I was using an older compile script locally - updating the correct one

hugod18:01:31

the tools-deps-native pr is now failing with the stack trace I originally posted

borkdude18:01:10

I'll take a look

borkdude18:01:09

@U0HFRSY0M What bb version are you using?

borkdude18:01:46

This is what I'm seeing with the last bb from homebrew: https://gist.github.com/borkdude/978f4336daf5879c22b131f4ce7dc9fe

borkdude19:01:16

I'm trying to push a branch, but it fails on trying to clone: git fetch --force origin +refs/heads/hugoduncan-update-to-tools-deps-latest:refs/remotes/origin/hugoduncan-update-to-tools-deps-latest

borkdude19:01:07

yes, I saw that

borkdude19:01:36

but right now I'm trying stuff and I can't get it to clone the repo

borkdude19:01:54

I'll try re-adding this project to circleci, something is weird

borkdude19:01:58

that helped...

hugod19:01:42

what are you trying to achieve with the changes? just updating to latest xcode, etc?

borkdude19:01:15

I wanted to ensure that the latest bb is used there since I see an acceptable error message locally

borkdude19:01:31

and xcode was necessary to update since 12.0.0 isn't supported, it just didn't run anymore

hugod19:01:15

what’s the local error?

borkdude19:01:33

am I doing something wrong?

hugod19:01:32

that error comes from the test using the babashka branch, which is still on tools.deps.alpha, vs the PR which is using my branch of tools.bbuild, updated to use tools.deps

borkdude19:01:57

hmm, I thought I cloned your changed locally

hugod19:01:35

maybe before I changed the test script

borkdude19:01:58

$ git pull [email protected]:hugoduncan/tools-deps-native-experiment.git update-to-tools-deps-latest
From 
 * branch            update-to-tools-deps-latest -> FETCH_HEAD
Already up to date.

borkdude19:01:05

is it sufficient to make that change on top of your latest commit?

hugod19:01:57

that is my latest commit, no?

borkdude19:01:01

O wait, it already has this?

(do (shell "git clone ")
      (shell {:dir "tools.bbuild"} "git checkout update-to-tools-build-0.9.0"))

borkdude19:01:04

I have that locally

borkdude19:01:39

I guess you also have to update the first one

borkdude19:01:51

when the repo already exists

borkdude19:01:07

yeah that worked

borkdude19:01:53

(this is with a local change to babashka)

hugod19:01:05

so it’s now throwing an exception with a message “clojure.core/vec” rather than “ns”?

borkdude19:01:38

what I did instead was print the SCI stacktrace instead of the internal stacktrace

hugod19:01:42

your last but one slack message (-6mins) is refusing to load here

borkdude19:01:04

that was a joke since I was waiting for your reply

hugod19:01:57

ahh - I am still trying to understand the new trace. an exception message of “clojure.core/vec” doesn’t say much to me, and the line numbers in the stack trace don’t seem to point to the actual problem.

borkdude19:01:58

we can also run this code with JVM Clojure right?

borkdude19:01:04

to check what JVM clojure.test does

borkdude19:01:26

this requires you to use the jvm pods library

hugod19:01:02

that particular test, probably - i’ll give it a go

hugod19:01:18

will have to be later though…

borkdude19:01:23

sure, no problem

hugod19:01:45

thanks for the help so far : )

hugod02:01:11

summary of current state: the error seems to be caused by the attempt to intern *compile-path* and *compiler-options*. Also the tools.build tests user reader-conditional which is unavailable in bb. any workarounds for either of the above?

borkdude11:01:20

The intern hacks are I think what you needed, but the ns needs to be a real namespace object, not a symbol. I fixed this in the branch

borkdude11:01:42

And I also added reader-conditional to SCI + bb master. I used --dev-build to install the babashka dev build in CI

borkdude11:01:56

In the hugoduncan-update-to-tools-deps-latest branch that I pushed

borkdude11:01:02

For testing locally, you can install the bb from master using:

bash <(curl -s ) --dir $(pwd) --dev-build
            

borkdude11:01:23

I'm getting:

Ran 33 tests containing 95 assertions.
0 failures, 5 errors.
which is slightly better than before, I hope...

borkdude11:01:42

So one thing is:

Unable to resolve classname: org.eclipse.aether.artifact.DefaultArtifact

borkdude11:01:01

in test-install-no-pom

borkdude11:01:17

Then there still is: Caused by: java.lang.NoSuchFieldException: ns

borkdude11:01:52

I pushed a more-or-less fix to update-to-tools-build-0.9.0 for the compile script. The vars were printed wrong and the .ns field was used to obtain the namespace name which you can't do in SCI right now

borkdude11:01:26

So now we're just left with:

FAIL in (test-compile) (/Users/borkdude/dev/tools.bbuild/src/test/clojure/clojure/tools/build/tasks/test_compile_clj.clj:17)
expected: (true? (.exists (jio/file (project-path "target/classes/foo/bar.class"))))
  actual: (not (true? false))

borkdude12:01:02

Ahj, I found another issue. pprint-ing a var in SCI doesn't work properly $ bb -e "(clojure.pprint/pprint #'inc)" #<Var@3d01336f: #object[clojure.core$inc 0x69addece "clojure.core$inc@69addece"]>

borkdude12:01:29

That fixes the weird errors too:

0 failures, 1 errors.

borkdude12:01:25

Ran 30 tests containing 96 assertions.
0 failures, 0 errors.

borkdude12:01:28

Tests also pass on Windows!

hugod12:01:05

it looks like I woke up at just the right time

borkdude13:01:53

I'll make a release of tools-deps-native binary so we can also merge the bbuild one

borkdude13:01:08

then we only have to release a new version of bb...

borkdude13:01:46

perhaps the compile-path thing can be fixed nicer in bb itself before I release it

borkdude13:01:53

anyway, the pod should be in good shape now

hugod13:01:11

I was wondering why reflect-config-cleaned.json is checked in?

borkdude13:01:24

maybe to have things more reproducible?

hugod13:01:33

I don’t see it ever being used as an input in its construction

borkdude13:01:02

I think it made the build fail on tools-deps-native ;-)

hugod13:01:52

woops, looks like I pushed instead of pulling. Hopefully you still have the branch locally

borkdude13:01:07

I do, shall I force push mine?

hugod13:01:31

please do

borkdude13:01:44

done, I'll re-run the build

borkdude13:01:59

I should have probably used a different branch, sorry ;)

hugod13:01:06

i’m just grateful for all the fixes 🙂

borkdude13:01:58

do you have any plans using tools.bbuild for real things?

hugod13:01:16

I want to use it with my makejack project. I also thought that a bb script to invoke a project’s (tools.build based) build scripts would be useful.

hugod13:01:53

Progress is very intermittent though…

borkdude13:01:07

no problem, just understanding the rationale better :-)

hugod13:01:11

Basically trying to make it easy to run tools.build based tooling with babashka. Something of a complement to the babashka first approach provided by babashka tasks.

borkdude13:01:44

ok, released tools-deps-native v0.1.0 here https://github.com/babashka/tools-deps-native

borkdude13:01:27

I'll take a look at: • gettting compile-path, etc into bb • cleaning up and merging the tools.bbuild branch later this week

hugod13:01:30

sounds good - thank you for the time you have put into this