Fork me on GitHub
#tools-build
<
2022-02-10
>
roklenarcic12:02:49

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.

borkdude12:02:41

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

roklenarcic13:02:46

Maybe a second alias that adds these paths and dependencies

borkdude13:02:58

yeah, you can add an alias that adds . maybe

Mark Wardle13:02:02

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

roklenarcic13:02:56

yeah I selected that and it didn’t help really

Mark Wardle13:02:55

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

roklenarcic13:02:02

I’ve got the standard setup:

roklenarcic13:02:18

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

roklenarcic13:02:27

I’ll ask the cursive chan

Mark Wardle13:02:57

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

roklenarcic13:02:46

Do I need to use Run with Deps?

roklenarcic13:02:05

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

roklenarcic13:02:29

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

Mark Wardle13:02:33

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 Wardle13:02:01

(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)14:02:22

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)14:02:20

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

roklenarcic15:02:20

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

Alex Miller (Clojure team)15:02:08

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

Alex Miller (Clojure team)15:02:39

does it work outside Cursive?

Alex Miller (Clojure team)15:02:59

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

Alex Miller (Clojure team)15:02:33

outside, try clj -Spath -A:build

roklenarcic15:02:53

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"

roklenarcic15:02:27

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

Alex Miller (Clojure team)15:02:52

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

Alex Miller (Clojure team)15:02:07

or that is the cursive repl I guess

Alex Miller (Clojure team)15:02:41

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

Alex Miller (Clojure team)15:02:45

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

roklenarcic15:02:36

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

roklenarcic15:02:35

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

borkdude12:02:30

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