Hello 👋🏻 I’m seeing a difference in behavior between cli and bb tasks and am curious why. I build my cljs like so.
clojure -T:build build-cljs
This works as expected when running in the terminal.
I define a bb task to run the same thing.
cljs:build-prod {:doc "build release CLJS"
:task (clojure {:dir "."} "-T:build build-cljs")}
And run it.
bb run cljs:build-prod
Exception in thread "main" Syntax error macroexpanding at (user.clj:1:1).
at clojure.lang.Compiler.load(Compiler.java:7648)
at clojure.lang.RT.loadResourceScript(RT.java:381)
at clojure.lang.RT.loadResourceScript(RT.java:368)
at clojure.lang.RT.maybeLoadResourceScript(RT.java:364)
at clojure.lang.RT.doInit(RT.java:486)
at clojure.lang.RT.init(RT.java:467)
at clojure.main.main(main.java:38)
Caused by: java.io.FileNotFoundException: Could not locate sc/api__init.class, sc/api.clj or sc/api.cljc on classpath.
...
Now, I have require sc.api in a user.clj file that is present only when the :dev alias is enabled. Afaict, that alias is not enabled here. Any idea why this may be happening?{:dir "."} isn't necessary when you are already in the current directory, not sure why you added it
perhaps try erasing .cpcache and re-run. else, create a repro and I'd be happy to clone and debug
Copy paste from the kit template 😃
Huh, ok so not expected. I’ll try that.
fwiw, I believe this is where it was originally from https://github.com/kit-clj/kit/blob/master/libs/deps-template/resources/io/github/kit_clj/kit/bb.edn
So the issue still occurs after deleting cpcache. I’ll try to make a repro.
ok, will look after dinner, thanks
(it's dinner time here now :))
Enjoy 😋
So you’re going to laugh… 😅 I’m new to bb. I jumped to the task runner docs in the book and copied https://book.babashka.org/#_introduction: bb run clean. I assumed the syntax for running commands was the same as npm. e.g., to run a named task, you do bb run [task]. The kit template I copied happened to define a task _named_ run!!
run {:doc "starts the app"
:task (if (fs/windows?)
(clojure {:dir "."} "-M:dev")
(shell {:dir "."} "clj -M:dev"))}
This task enabled the :dev alias which added my dev user.clj to the cp, resulting in this error.
Weird set of things. I have my answer now — delete the run task.omg
I think bb should emit a warning for this case, I think there's already an issue about it. glad you solved it
you can just rename the run task to dev, that's how I usually call it
perhaps you can even contribute this back to kit, so others won't run into the same
Maybe a simple log line at the top of execution
[bb] Running task "run"