tools-build

roklenarcic 2022-02-10T12:53:49.663379Z

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.

borkdude 2022-02-10T12:57:41.646089Z

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

roklenarcic 2022-02-10T13:07:10.343479Z

roklenarcic 2022-02-10T13:07:46.788469Z

Maybe a second alias that adds these paths and dependencies

borkdude 2022-02-10T13:07:58.778429Z

yeah, you can add an alias that adds . maybe

Mark Wardle 2022-02-10T13:32:02.531299Z

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

roklenarcic 2022-02-10T13:34:56.863789Z

yeah I selected that and it didn’t help really

Mark Wardle 2022-02-10T13:35:55.437799Z

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

roklenarcic 2022-02-10T13:37:02.812749Z

I’ve got the standard setup:

roklenarcic 2022-02-10T13:39:18.774579Z

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

roklenarcic 2022-02-10T13:39:27.260939Z

I’ll ask the cursive chan

Mark Wardle 2022-02-10T13:39:57.900229Z

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

roklenarcic 2022-02-10T13:43:46.483249Z

Do I need to use Run with Deps?

roklenarcic 2022-02-10T13:44:05.384699Z

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

roklenarcic 2022-02-10T13:45:29.712209Z

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

Mark Wardle 2022-02-10T13:48:33.375039Z

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
Mark Wardle 2022-02-10T13:53:01.566919Z

(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

roklenarcic 2022-02-10T15:20:20.535389Z

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

roklenarcic 2022-02-10T15:23:53.747679Z

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"

roklenarcic 2022-02-10T15:24:27.587099Z

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

roklenarcic 2022-02-10T15:33:36.608709Z

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

roklenarcic 2022-02-10T15:34:35.071419Z

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

borkdude 2022-02-10T12:58:30.114719Z

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