tools-build 2022-02-10

What’s a good way to setup project in Cursive to be able to develop the build.clj file? Usually it’s outside the normal source tree it has separate dependencies.

@roklenarcic you can maybe open a REPL with the :build alias and then evaluate the build.clj in the REPL?

Maybe a second alias that adds these paths and dependencies

yeah, you can add an alias that adds . maybe

You can choose a tools alias. Open the clojure deps panel:

yeah I selected that and it didn’t help really

Weird. Did you click refresh, and is your build file in your deps.edn file?

I’ve got the standard setup:

when I start REPL I cannot load build.clj and if I try to just evaluate single expressions I get:

(defn test "Run the tests." [opts]
  (bb/run-tests opts))
Syntax error compiling at (build.clj:12:1).
Unable to resolve symbol: defn in this context

I’ll ask the cursive chan

Ok. Presumably you are including that alias in your REPL set-up?

Do I need to use Run with Deps?

if you pick the IntelliJ project classpath, then it uses the aliases from clojure deps tab

How would you start REPL into this tool build from command line btw?

My build files are so simple I actually haven’t loaded in my REPL, but I guess you could add an :extra-paths in your alias? Did you try something like :

☝️ 1

(I’ve always used ‘run with deps’ so I know my REPL is in the exact state as I expect, but I don’t know whether that is what others do)

Alex Miller (Clojure team) 2022-02-10T14:08:22.771549Z

because clj -T adds :paths ["."] (and Cursive won't when using an alias), I would recommend adding it explicitly as in Mark's example and then starting with the alias

Alex Miller (Clojure team) 2022-02-10T14:09:20.045589Z

and in particular, use :paths, not :extra-paths to replace the project paths

Tried with that and it doesn’t work, I still get the same messages

Alex Miller (Clojure team) 2022-02-10T15:22:08.417729Z

well, it should :) what does (System/getProperty "java.class.path") report ?

Alex Miller (Clojure team) 2022-02-10T15:22:39.899709Z

does it work outside Cursive?

Alex Miller (Clojure team) 2022-02-10T15:22:59.526999Z

if so, then I'd move this to #cursive

Alex Miller (Clojure team) 2022-02-10T15:23:33.480939Z

outside, try clj -Spath -A:build

builds work, if I say clj -T:build they work, CP is:

"/Users/roklenarcic/Library/Application Support/JetBrains/IntelliJIdea2021.3/plugins/clojure-plugin/lib/nrepl-0.8.3.jar:/Users/roklenarcic/clojure-projects/memento/test:/Users/roklenarcic/clojure-projects/memento:/Users/roklenarcic/clojure-projects/memento/src:/Users/roklenarcic/.m2/repository/com/google/guava/guava/30.1.1-jre/guava-30.1.1-jre.jar:/Users/roklenarcic/.gitlibs/libs/io.github.cognitect-labs/test-runner/48c3c67f98362ba1e20526db4eeb6996209c050a/src:/Users/roklenarcic/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/Users/roklenarcic/.m2/repository/org/clojure/core.memoize/1.0.236/core.memoize-1.0.236.jar:/Users/roklenarcic/.m2/repository/org/clojure/test.check/1.1.1/test.check-1.1.1.jar:/Users/roklenarcic/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/roklenarcic/.m2/repository/com/google/errorprone/error_prone_annotations/2.5.1/error_prone_annotations-2.5.1.jar:/Users/roklenarcic/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/Users/roklenarcic/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/roklenarcic/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:/Users/roklenarcic/.m2/repository/org/checkerframework/checker-qual/3.8.0/checker-qual-3.8.0.jar:/Users/roklenarcic/.m2/repository/org/clojure/tools.cli/1.0.206/tools.cli-1.0.206.jar:/Users/roklenarcic/.m2/repository/org/clojure/tools.namespace/1.1.0/tools.namespace-1.1.0.jar:/Users/roklenarcic/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/Users/roklenarcic/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar:/Users/roklenarcic/.m2/repository/org/clojure/core.cache/1.0.207/core.cache-1.0.207.jar:/Users/roklenarcic/.m2/repository/org/clojure/java.classpath/1.0.0/java.classpath-1.0.0.jar:/Users/roklenarcic/.m2/repository/org/clojure/tools.reader/1.3.4/tools.reader-1.3.4.jar:/Users/roklenarcic/.m2/repository/org/clojure/data.priority-map/1.0.0/data.priority-map-1.0.0.jar"

So it does contain /Users/roklenarcic/clojure-projects/memento where build.clj is

Alex Miller (Clojure team) 2022-02-10T15:27:52.410069Z

and does that cp match what you see in a repl in cursive?

Alex Miller (Clojure team) 2022-02-10T15:28:07.602989Z

or that is the cursive repl I guess

Alex Miller (Clojure team) 2022-02-10T15:28:41.965289Z

so you can't (require 'build) in the Cursive repl?

Alex Miller (Clojure team) 2022-02-10T15:29:45.992309Z

possible you may also need to mess with the project settings in Cursive to mark root as a src folder for this use

It seems that CP is wrong, I see that when going clj -Spath -A:build I have tools.build in my CP, but in cursive I don’t have it, even though I have build alias selected in Tool Aliases

Even if I select Run with Deps and put in build as alias

Alex Miller (Clojure team) 2022-02-10T15:48:50.956919Z

maybe :build ?

Alex Miller (Clojure team) 2022-02-10T15:51:22.038739Z

aliases are keywords

load-file also works, regardless if the file is on the classpath