Fork me on GitHub
#babashka
<
2021-11-21
>
Ben Sless07:11:58

Idle thought - when is someone going to use the babashka tasks API to implement a build tool and package manager?

hugod22:11:11

I’m working on makejack which provides build tasks that mostly are capable of running with bb. It includes a standalone bb script , which you can download and run https://github.com/hugoduncan/makejack/blob/main/mj Still alpha at the moment, but I’m using it one other project. The project is here https://github.com/hugoduncan/makejack

hugod22:11:37

@U04V15CAJ has updated bb, and together with a tools-deps-native pod, we can run tools.build tasks.

awb9913:11:33

This is my babashka build config.

awb9913:11:37

Works amazing!

🎉 2
adkelley21:11:00

I'm having problem with bb finding 'clojure.main' I installed clojure using brew, and it's located in '/opt/homebrew/bin/clojure'. But when I attempt to run a clojure program using bb (i.e., bb -m foo.main) I get the error 'Could not find or load main class clojure.main' I have clojure as a dependency in my bb.edn file. Thanks in advance for any help in solving this one.

borkdude21:11:54

Hi! You don't need clojure as a dependency for babahska. Babashka is a standalone binary. This error message seems to be coming from a JVM, perhaps because babashka is trying to download dependencies for which it uses clojure.

borkdude21:11:15

Can you try just clojure --version and see what it prints?

borkdude21:11:36

Note that you have to use the clojure tap, not the package from homebrew itself: https://clojure.org/guides/getting_started#_installation_on_mac_via_homebrew

adkelley21:11:46

Thanks. It's shows me the help docs. Note I also installed java using brew. opt/homebrew/opt/openjdk/bin

borkdude21:11:23

--version please

adkelley21:11:40

1.10.3.1029

borkdude21:11:55

ok, that looks normal. I'll be right back.

adkelley21:11:59

I didn't use the clojure tap though for homebrew. I used the core tap. Let me reinstall

adkelley21:11:50

No difference

borkdude22:11:50

ok, I'm back now

borkdude22:11:10

can you test this? clojure -M -e '(+ 1 2 3)'?

adkelley22:11:22

That works fine

adkelley22:11:28

I'm attempting the example from your Project Setup section in the Babashka book. bb -m my-project.main Error: Could not find or load main class clojure.main Caused by: java.lang.ClassNotFoundException: clojure.main

adkelley22:11:22

. ├── bb.edn └── script   └── my_project     └── main.clj 2 directories, 2 files

borkdude22:11:38

what is in your bb.edn here?

borkdude22:11:09

and which version of bb do you have? bb --version

adkelley22:11:04

Interesting! That comes back Error: Could not find or load main class clojure.main Caused by: java.lang.ClassNotFoundException: clojure.main. Yet, I'm able to run bb scripts

adkelley22:11:36

I installed bb using homebrew - /opt/homebrew/bin/bb

borkdude22:11:52

which version?

adkelley22:11:55

Ahh... When I get out of the project directory. bb --version works fine. V0.6.5

borkdude22:11:20

there might be an error in your bb.edn. I tried the sample project from the book and it worked fine here

borkdude22:11:43

if you can put up this repro in a github repo I can try it locally

adkelley22:11:50

{:paths ["script"]  :deps {medley/medley {:mvn/version "1.3.0"}}}

borkdude22:11:24

can you go out of this directory and try: bb clojure --version

adkelley22:11:50

I got an exception

adkelley22:11:05

Exception in thread "main" java.io.FileNotFoundException: /Users/alexkelley/.clojure/.cpcache/363A78F07197DB7FD0EDF27138B9FAFF.cp (No such file or directory)

borkdude22:11:31

can you try: rm -rf ~/.deps.clj

borkdude22:11:37

and then try again?

borkdude22:11:08

don't worry, .deps.clj is created by bb, you can safely remove it

adkelley22:11:17

Could not find /Users/alexkelley/.deps.clj/1.10.3.1029/ClojureTools/clojure-tools-1.10.3.1029.jar Downloading tools jar from https://download.clojure.org/install/clojure-tools-1.10.3.1029.zip to /Users/alexkelley/.deps.clj/1.10.3.1029/ClojureTools Exception in thread "main" java.io.FileNotFoundException: /Users/alexkelley/.clojure/.cpcache/363A78F07197DB7FD0EDF27138B9FAFF.cp (No such file or directory)

borkdude22:11:01

Does the directory /Users/alexkelley/.clojure exist?

adkelley22:11:38

Yes. /Users/alexkelley/.clojure ├── deps.edn └── tools   └── tools.edn 1 directory, 2 files

borkdude22:11:01

Does the directory /Users/alexkelley/.clojure/.cpcache exist?

borkdude22:11:59

and no file:

/Users/alexkelley/.clojure/.cpcache/363A78F07197DB7FD0EDF27138B9FAFF.cp
or so?

borkdude22:11:14

what do you get for java --version?

adkelley22:11:42

openjdk 17.0.1 2021-10-19 OpenJDK Runtime Environment Homebrew (build 17.0.1+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.1+0, mixed mode, sharing)

adkelley22:11:16

Note I'm on an M1 Macbook Pro

borkdude22:11:12

I can't reproduce this...

borkdude@MBP2019 /tmp/project $ rm -rf  ~/.clojure/.cpcache/
borkdude@MBP2019 /tmp/project $ rm -rf ~/.m2/repository/medley
borkdude@MBP2019 /tmp/project $ java --version
openjdk 17.0.1 2021-10-19
OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05, mixed mode, sharing)
borkdude@MBP2019 /tmp/project $ bb -m my-project.main
Downloading: medley/medley/1.3.0/medley-1.3.0.pom from clojars
Downloading: medley/medley/1.3.0/medley-1.3.0.jar from clojars
{1 {:id 1}, 2 {:id 2}}

borkdude22:11:59

Are you able to run JVM Clojure projects with dependencies using clojure?

borkdude22:11:04

Try this:

$ cp bb.edn deps.edn
$ clojure -M -m my-project.main
{1 {:id 1}, 2 {:id 2}}

adkelley22:11:45

Interesting. Now the bb version works?

adkelley22:11:38

tree /Users/alexkelley/.clojure/.cpcache /Users/alexkelley/.clojure/.cpcache ├── 2663883992.basis ├── 2663883992.cp ├── 2663883992.libs ├── 4E9D4371BD0E58D039BDA63A46AF924D.basis ├── 4E9D4371BD0E58D039BDA63A46AF924D.cp └── 4E9D4371BD0E58D039BDA63A46AF924D.libs

borkdude22:11:22

can you try to remove this .cpcache dir and then try again with bb only?

borkdude22:11:11

Interesting...

adkelley22:11:36

tree /Users/alexkelley/.clojure/.cpcache   /Users/alexkelley/.clojure/.cpcache ├── 4E9D4371BD0E58D039BDA63A46AF924D.basis ├── 4E9D4371BD0E58D039BDA63A46AF924D.cp └── 4E9D4371BD0E58D039BDA63A46AF924D.libs

borkdude22:11:59

Please write up an issue with details from this discussion if you have the time... I'll take a look at reproducing the issue locally. I'm not sure what it is right now

adkelley22:11:47

Now my projects are working again! Yay!

borkdude22:11:57

Perhaps the clojure bash script copied some file that the bb one didn't do or so.

borkdude22:11:02

Which made it work

adkelley22:11:44

I will. This is very strange. Clearly that was the trigger.

adkelley22:11:10

Thank you so much! I've been trying to get back on track after upgrading to an M1 last week.

👍 1
adkelley22:11:15

Where shall I post my write up?