Fork me on GitHub
#cursive
<
2023-11-03
>
octahedrion08:11:42

I don't know if this is a Cursive thing or an IntelliJ thing, but I have my editor split left-right with the REPL on the right and sometimes when I resize the partition to assign more width to the REPL, the left editor half in resizing looses its position, the current line moves somewhere else. It's a minor annoyance but it would be nice if it resized and kept the same position.

hlship17:11:22

I have a problem when using IntelliJ on a deps.edn multi-project. The repo is public: https://github.com/pedestal/pedestal Essentially, I have the sub-modules cross-wired to each other using the last published version:

io.pedestal/pedestal.log {:mvn/version "0.6.0"}
        io.pedestal/pedestal.metrics {:mvn/version "0.6.0"}
        io.pedestal/pedestal.interceptor {:mvn/version "0.6.0"}
        io.pedestal/pedestal.route {:mvn/version "0.6.0"}
but of course, when I'm developing, I need the "live" versions, so:
:aliases
 {:local
  {:override-deps {io.pedestal/pedestal.log {:local/root "../log"}
                   io.pedestal/pedestal.metrics {:local/root "../metrics"}
                   io.pedestal/pedestal.interceptor {:local/root "../interceptor"}
                   io.pedestal/pedestal.route {:local/root "../route"}}}
That works fine for the command line, but I think Cursive is evaluating the links from the wrong location (the project root, not the sub-module), so I when I enable my :local alias I get errors:
The following errors were found during project resolve: /Users/howard.lewisship/workspaces/github/pedestal/aws/deps.edn: Local lib io.pedestal/pedestal.log not found: ../log /Users/howard.lewisship/workspaces/github/pedestal/interceptor/deps.edn: Local lib io.pedestal/pedestal.log not found: ../log

1
cfleming21:11:26

Which modules do you have added? I’ve added aws, interceptor, jetty, log, pedestal, route, service and service-tools. I’m seeing errors like:

The following errors were found during project resolve: /Users/colin/dev/pedestal/jetty/deps.edn: The following libs must be prepared before use: [io.pedestal/pedestal.service] /Users/colin/dev/pedestal/service-tools/deps.edn: The following libs must be prepared before use: [io.pedestal/pedestal.service]

hlship21:11:13

You need to do a prep in the service module first; it has a Java class that the prep compiles.

hlship21:11:18

Thanks for looking into this.

cfleming21:11:11

Yep, I just figured that out, thanks, I’ve not used the prep stuff before.

hlship21:11:29

I'm about to go OOTO and may be spottily reachable as I'm flying to Sao Paolo this weekend.

cfleming21:11:04

Ok. I’ll try to figure this out, otherwise let me know when you’re available.

hlship21:11:23

Just saying if you don't hear from me for a bit, that's why.

cfleming21:11:32

I’ve done a clj -X:deps prep in service, but it doesn’t seem to be doing anything.

hlship21:11:57

clojure -X:deps:local prep

cfleming21:11:40

Nope. I’m getting no output, and it’s not creating target/classes

hlship21:11:56

Odd, that works in the GitHub action, so it should work for you.

cfleming21:11:07

I’ll see if I can figure it out.

hlship21:11:55

You're right, not working here either.

cfleming21:11:19

I’m doing for dir in aws interceptor jetty log route service service-tools; echo $dir; cd $dir; clj -X:deps:local prep; cd ..; end (in fish shell), and I’m not seeing any target dirs created.

hlship21:11:39

I have to run.

cfleming21:11:48

Ok. Me too, actually.

cfleming21:11:58

I’ll look at this later and see if I can work it out.

cfleming22:11:44

Ok, I had another quick go. I managed to build manually: clj -T:build compile-java in service. And once I do that, I can sync the whole project, even with the local alias selected. And when I select and deselect the local alias, I see the deps correctly changing from library deps to module deps. Which version of Cursive are you using?

hlship01:11:30

You're right about the build target; it's likely broken on CI and I do deploy builds locally.

hlship01:11:32

I'm on 1.13.0-2023.2

hlship01:11:45

So I need to figure out why I'm seeing something different than you.

hlship17:11:42

I looks like I can make it work by using full paths, i.e., :local/root "/Users/workspaces/github/pedestal/log, but that doesn't work on CI or on other dev's computers.

Alex Miller (Clojure team)18:11:45

I think this is actually a tools.deps bug that I was working on last week https://clojure.atlassian.net/browse/TDEPS-256

Alex Miller (Clojure team)18:11:01

I'm almost done with it, still testing some things, may have a chance to get it integrated later today

hlship19:11:37

I'm surprised because using the alias & relative paths seems to work well with clj.

Alex Miller (Clojure team)19:11:12

really depends which api paths you're going through

Alex Miller (Clojure team)19:11:23

if your current directory is the project directory, that should be fine (the CLI basically requires this). I'm guessing the Java current directory is at the project root when Cursive is doing whatever creates the basis in this case (not in the subdir)

cfleming19:11:13

Ok, let me know if this does look like a Cursive bug in the end. Under Cursive the CWD will be the IntelliJ CWD, and Cursive handles this using *the-dir*.

Alex Miller (Clojure team)19:11:42

do you ever call tools.deps/create-basis and pass :project ?

cfleming20:11:16

Now I delegate everything to deps.clj. So I call deps.clj, and when that needs to call deps it passes me the args for make-classpath2 and I just call that directly. The only bit that I’ve vendored into Cursive from that is -main, to avoid it calling System/exit:

; Code from clojure.tools.deps.alpha.script.make-classpath2/-main, to avoid System/exit
(let [{:keys [options errors]} (make-classpath/parse-opts args)]
 (if (seq errors)
   ; TODO error handling
   (run! println errors)
   (make-classpath/run options)))
(catch Throwable t
 (throw (RuntimeException. (str :cursive.deps.project/resolve-exception
                                ":"
                                (.getMessage t))))))))))))

Alex Miller (Clojure team)20:11:06

and you're setting the-dir to the project directory around that?

Alex Miller (Clojure team)20:11:16

if so, then I don't think the error I mentioned above is relevant

cfleming20:11:32

Ok, I’ll try to reproduce the problem and see what I can see.

Alex Miller (Clojure team)20:11:15

there have been problems like this resolved long ago, so I'm assuming recent versions of CLI, tools.deps etc

cfleming20:11:51

Yes, I only support the last couple of versions of deps.clj because borkdude made some changes to support the integration.

hlship20:11:56

Example: from the interceptor sub-dir:

> clj -Spath | sed 's/:/\n/g'
src
/Users/howard.lewisship/.m2/repository/io/pedestal/pedestal.log/0.6.0/pedestal.log-0.6.0.jar
/Users/howard.lewisship/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.async/1.6.673/core.async-1.6.673.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.match/1.0.1/core.match-1.0.1.jar
/Users/howard.lewisship/.m2/repository/io/dropwizard/metrics/metrics-core/4.2.18/metrics-core-4.2.18.jar
/Users/howard.lewisship/.m2/repository/io/dropwizard/metrics/metrics-jmx/4.2.18/metrics-jmx-4.2.18.jar
/Users/howard.lewisship/.m2/repository/io/opentracing/opentracing-api/0.33.0/opentracing-api-0.33.0.jar
/Users/howard.lewisship/.m2/repository/io/opentracing/opentracing-util/0.33.0/opentracing-util-0.33.0.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar
/Users/howard.lewisship/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar
/Users/howard.lewisship/.m2/repository/org/clojure/tools.analyzer.jvm/1.2.2/tools.analyzer.jvm-1.2.2.jar
/Users/howard.lewisship/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar
/Users/howard.lewisship/.m2/repository/io/opentracing/opentracing-noop/0.33.0/opentracing-noop-0.33.0.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.memoize/1.0.253/core.memoize-1.0.253.jar
/Users/howard.lewisship/.m2/repository/org/clojure/tools.analyzer/1.1.0/tools.analyzer-1.1.0.jar
/Users/howard.lewisship/.m2/repository/org/clojure/tools.reader/1.3.6/tools.reader-1.3.6.jar
/Users/howard.lewisship/.m2/repository/org/ow2/asm/asm/9.2/asm-9.2.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.cache/1.0.225/core.cache-1.0.225.jar
/Users/howard.lewisship/.m2/repository/org/clojure/data.priority-map/1.1.0/data.priority-map-1.1.0.jar
> clj -Spath -X:local | sed 's/:/\n/g'
src
/Users/howard.lewisship/workspaces/github/pedestal/log/src
/Users/howard.lewisship/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.async/1.6.673/core.async-1.6.673.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.match/1.0.1/core.match-1.0.1.jar
/Users/howard.lewisship/.m2/repository/io/dropwizard/metrics/metrics-core/4.2.19/metrics-core-4.2.19.jar
/Users/howard.lewisship/.m2/repository/io/dropwizard/metrics/metrics-jmx/4.2.19/metrics-jmx-4.2.19.jar
/Users/howard.lewisship/.m2/repository/io/opentracing/opentracing-api/0.33.0/opentracing-api-0.33.0.jar
/Users/howard.lewisship/.m2/repository/io/opentracing/opentracing-util/0.33.0/opentracing-util-0.33.0.jar
/Users/howard.lewisship/.m2/repository/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar
/Users/howard.lewisship/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar
/Users/howard.lewisship/.m2/repository/org/clojure/tools.analyzer.jvm/1.2.2/tools.analyzer.jvm-1.2.2.jar
/Users/howard.lewisship/.m2/repository/io/opentracing/opentracing-noop/0.33.0/opentracing-noop-0.33.0.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.memoize/1.0.253/core.memoize-1.0.253.jar
/Users/howard.lewisship/.m2/repository/org/clojure/tools.analyzer/1.1.0/tools.analyzer-1.1.0.jar
/Users/howard.lewisship/.m2/repository/org/clojure/tools.reader/1.3.6/tools.reader-1.3.6.jar
/Users/howard.lewisship/.m2/repository/org/ow2/asm/asm/9.2/asm-9.2.jar
/Users/howard.lewisship/.m2/repository/org/clojure/core.cache/1.0.225/core.cache-1.0.225.jar
/Users/howard.lewisship/.m2/repository/org/clojure/data.priority-map/1.1.0/data.priority-map-1.1.0.jar
deps.edn:
{:paths ["src"]
 :deps {org.clojure/clojure {:mvn/version "1.11.1"}
        org.clojure/core.async {:mvn/version "1.6.673"}
        io.pedestal/pedestal.log {:mvn/version "0.6.0"}
        ;; Error interceptor tooling
        org.clojure/core.match {:mvn/version "1.0.1"
                                :exclusions [org.clojure/clojurescript]}}
 :aliases
 {:local
  {:override-deps {io.pedestal/pedestal.log {:local/root "../log"}}}}}

hlship21:11:49

One more thing: I think this is perhaps caused by the interaction of the :local alias; in the tests subproject, I use :local/root but not the alias and it works fine in IntellJ.