Skip to content

Conversation

@expez
Copy link
Member

@expez expez commented Jun 25, 2021

Previously this op was built on top of alembic, but that lib no longer
seems to be maintained at all so we're moving to pomegranate.

tools.deps would've been another alternative by their add-lib
operation has yet to be merged to the main branch. Once it's merged and
has proven itself in the wild nothing prevents us from moving over,
though, if that solution proves to be better in some way.

@expez
Copy link
Member Author

expez commented Jun 25, 2021

@benedekfazekas this seems to fail due to the mranderson pass. Is that something you have time to investigate?

@bbatsov
Copy link
Member

bbatsov commented Jun 25, 2021

Now that the other PR is merged, I guess you can rebase this one on top of master.

@vemv
Copy link
Member

vemv commented Jun 25, 2021

I'd try to replicate this test as part of this PR: https://github.com/clojure-emacs/orchard/blob/dbe1bef72697a89843763dd112d151a9f365e5c8/test/orchard/java/classpath_test/third_party_compat_test.clj - else I'd fear that users of this feature could have issues that could manifest themselves in third-party libs.

(in this case the when-not conditional is not needed)

@expez
Copy link
Member Author

expez commented Jun 25, 2021

Now that the other PR is merged, I guess you can rebase this one on top of master.

Done

I'd try to replicate this test as part of this PR

Thanks. That's a good idea. I read some of the discussion you linked yesterday, but it's not entirely clear what this test is testing.

(deftest works
    (is (seq (clojure.java.classpath/classpath-directories))
        "The presence of `clojure.java` does not affect third-party libraries"))

If you get stuff back it works, otherwise you got an exception as the failure mode?

@vemv
Copy link
Member

vemv commented Jun 25, 2021

If you get stuff back it works, otherwise you got an exception as the failure mode?

The side-effects of using dynapath were causing the result of (clojure.java.classpath/classpath-directories) to be an empty list

@benedekfazekas
Copy link
Member

will have a look

@expez
Copy link
Member Author

expez commented Jun 25, 2021

Are you married to *warn-on-reflection* in the :dev profile @bbatsov? Personally I only turn this on when doing performance tuning (as that's the only downside of reflections).

Adding pomegranate makes the REPL quite noisy on startup now:

Reflection warning, cemerick/pomegranate/aether.clj:109:49 - reference to field getMessage on java.lang.Object can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:109:49 - reference to field getMessage on java.lang.Object can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:143:47 - call to method newLocalRepositoryManager on java.lang.Object can't be resolved (no such method).
Reflection warning, cemerick/pomegranate/aether.clj:173:3 - call to method setSnapshotPolicy can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:173:3 - call to method setReleasePolicy can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:181:7 - call to method addPassword on org.eclipse.aether.util.repository.AuthenticationBuilder can't be resolved (argument types: java.lang.Object).
Reflection warning, cemerick/pomegranate/aether.clj:182:7 - call to method addPrivateKey can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:179:3 - reference to field build can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:188:5 - call to method setAuthentication can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:199:34 - reference to field build can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:201:7 - call to method setProxy can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:362:5 - call to method deploy can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:381:5 - call to method install can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:470:36 - reference to field getDependency can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:476:29 - reference to field getChildren can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:614:31 - call to method setProperties can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:621:39 - reference to field getMirrorSelector can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:622:39 - call to method getMirror can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:626:7 - call to method resolveArtifacts can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:630:10 - call to method resolveVersion can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:630:10 - call to method resolveVersion can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:706:33 - reference to field getArtifact can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:706:33 - call to method setProperties can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:703:15 - call to method setArtifact can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:804:65 - reference to field getMirrorSelector can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:805:65 - call to method getMirror can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:800:31 - call to org.eclipse.aether.collection.CollectRequest ctor can't be resolved.
Reflection warning, cemerick/pomegranate/aether.clj:810:7 - call to method resolveDependencies can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:811:7 - call to method collectDependencies can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate/aether.clj:819:3 - reference to field getRoot can't be resolved.
Reflection warning, cemerick/pomegranate.clj:20:13 - call to method getDeclaredMethod can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate.clj:22:5 - call to method setAccessible can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate.clj:23:5 - call to method invoke can't be resolved (target class is unknown).
Reflection warning, cemerick/pomegranate.clj:32:17 - reference to field getParent can't be resolved.

@expez
Copy link
Member Author

expez commented Jun 25, 2021

It's been a while since I ran a snapshot locally and I'm not sure why it isn't working.

I did:

(setq cider-jack-in-lein-plugins
      '(("refactor-nrepl/refactor-nrepl" "3.0.0-SNAPSHOT" :predicate cljr--inject-middleware-p)
        ("cider/cider-nrepl" "0.26.0-SNAPSHOT")))

And that gave me:

[nREPL] Starting server via "c:/programdata/chocolatey/bin/lein.bat" update-in :dependencies conj ^"[nrepl/nrepl \^"0.8.3\^"]^" -- update-in :plugins conj ^"[refactor-nrepl/refactor-nrepl \^"3.0.0-SNAPSHOT\^"]^" -- update-in :plugins conj ^"[cider/cider-nrepl \^"0.26.0-SNAPSHOT\^"]^" -- repl :headless :host localhost

The REPL starts, but with a warning:

WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.1 (package: 20210413.733) and n/a, respectively.

Checking manually, the middleware isn't responding to the version check and when I inspect the classpath no refactor-nrepl is on there. The refactor-nrepl-3.0.0-SNAPSHOT jar did get downloaded though.

I can't see any errors in any of the nrepl-buffers. Does that mean it just crashed silently on startup? Suggestions?

@bbatsov
Copy link
Member

bbatsov commented Jun 25, 2021

Are you married to warn-on-reflection in the :dev profile @bbatsov? Personally I only turn this on when doing performance tuning (as that's the only downside of reflections).

I don't care about the reflection warnings, but many people do. If we disable this when we develop, then they'll suffer when we ship.

@vemv
Copy link
Member

vemv commented Jun 25, 2021

Specifically, it can be a pain when one invokes lein repl in end-user projects with warn-on-reflection and one sees a wall of warns coming from clojure-emacs tools.

i.e. even if performance might mostly be unaffected, it's pretty noisy.

@expez
Copy link
Member Author

expez commented Jun 25, 2021

Good points! Hadn't considered that it'll look real bad when someone turns on *warn-on-reflection* in their own project and refactor-nrepl spews a wall of warnings.

Guess it might be prudent to fix these reflection warnings in pomegranate prior to cutting the 3.0.0 release. I'm sure they'll be happy with a PR over at clj-commons fixing this.

edit: I'll hold off on doing that until we get this working, though.

@bbatsov
Copy link
Member

bbatsov commented Jun 25, 2021

The only reason I know that people care about this is because people are constantly complaining when there are oversights in Orchard and cider-nrepl. 😆

@expez
Copy link
Member Author

expez commented Jun 25, 2021

@bbatsov I think something went wrong when you built the latest snapshot. It's almost half the size of the 2.5.1 release.

When I inspect it all the .class files of the inlined deps are missing:

image

Or maybe that's the new normal with the latest mranderson release?

@bbatsov
Copy link
Member

bbatsov commented Jun 25, 2021

I did a "make clean deploy", as I always do. Still, it seems the deps weren't properly inlined.

@expez expez force-pushed the hotload-deps branch 2 times, most recently from f27a97a to 12ab7b0 Compare June 29, 2021 08:24
@bbatsov
Copy link
Member

bbatsov commented Jul 1, 2021

Time to rebase here I guess.

@expez expez force-pushed the hotload-deps branch 6 times, most recently from 46b42b1 to ebaffdf Compare July 1, 2021 22:32
@expez
Copy link
Member Author

expez commented Jul 1, 2021

Rebased.

The lint run fails and says this:

Possibly confusing dependencies found:
[clj-commons/pomegranate "1.2.1" :exclusions [org.clojure/clojure org.slf4j/jcl-over-slf4j org.tcrawley/dynapath]] -> [org.apache.httpcomponents/httpclient "4.5.8"]
 overrides
[clj-commons/pomegranate "1.2.1" :exclusions [org.clojure/clojure org.slf4j/jcl-over-slf4j org.tcrawley/dynapath]] -> [org.apache.maven.wagon/wagon-http "3.3.4"] -> [org.apache.maven.wagon/wagon-http-shared "3.3.4"] -> [org.apache.httpcomponents/httpclient "4.5.9" :exclusions [commons-logging]]
 and
[clj-commons/pomegranate "1.2.1" :exclusions [org.clojure/clojure org.slf4j/jcl-over-slf4j org.tcrawley/dynapath]] -> [org.apache.maven.wagon/wagon-http "3.3.4"] -> [org.apache.httpcomponents/httpclient "4.5.9" :exclusions [commons-logging]]

Consider using these exclusions:
[clj-commons/pomegranate "1.2.1" :exclusions [org.slf4j/jcl-over-slf4j org.clojure/clojure org.apache.httpcomponents/httpclient org.tcrawley/dynapath]]

Aborting due to :pedantic? :abort
Error encountered performing task 'run' with profile(s): 'base,system,user,provided,1.10,clj-kondo'
Suppressed exit
Makefile:21: recipe for target 'kondo' failed
make: *** [kondo] Error 1

Exited with code exit status 2

CircleCI received exit code 2

Yet locally I get no conflicting deps:

$ lein deps :tree
 [cider/cider-nrepl "0.25.9" :scope "provided" :exclusions [[org.clojure/clojure]]]
 [cider/orchard "0.7.1" :exclusions [[org.clojure/clojure]]]
   [org.tcrawley/dynapath "1.1.0" :exclusions [[org.clojure/clojure]]]
 [cider/piggieback "0.5.2" :scope "test" :exclusions [[org.clojure/clojure]]]
 [clj-commons/fs "1.6.307" :exclusions [[org.clojure/clojure]]]
   [org.apache.commons/commons-compress "1.20"]
   [org.tukaani/xz "1.8"]
 [clj-commons/pomegranate "1.2.1" :exclusions [[org.clojure/clojure] [org.slf4j/jcl-over-slf4j] [org.tcrawley/dynapath]]]
   [org.apache.httpcomponents/httpclient "4.5.8"]
     [commons-codec "1.11"]
     [commons-logging "1.2"]
   [org.apache.httpcomponents/httpcore "4.4.11"]
   [org.apache.maven.resolver/maven-resolver-api "1.3.3"]
   [org.apache.maven.resolver/maven-resolver-connector-basic "1.3.3"]
   [org.apache.maven.resolver/maven-resolver-impl "1.3.3"]
   [org.apache.maven.resolver/maven-resolver-spi "1.3.3"]
   [org.apache.maven.resolver/maven-resolver-transport-file "1.3.3"]
   [org.apache.maven.resolver/maven-resolver-transport-http "1.3.3"]
   [org.apache.maven.resolver/maven-resolver-transport-wagon "1.3.3"]
   [org.apache.maven.resolver/maven-resolver-util "1.3.3"]
   [org.apache.maven.wagon/wagon-http "3.3.4"]
     [org.apache.maven.wagon/wagon-http-shared "3.3.4"]
       [org.jsoup/jsoup "1.12.1"]
   [org.apache.maven.wagon/wagon-provider-api "3.3.4"]
   [org.apache.maven/maven-resolver-provider "3.6.1"]
     [javax.inject "1"]
     [org.apache.maven/maven-model-builder "3.6.1"]
       [org.apache.maven/maven-artifact "3.6.1"]
         [org.apache.commons/commons-lang3 "3.8.1"]
       [org.apache.maven/maven-builder-support "3.6.1"]
       [org.codehaus.plexus/plexus-component-annotations "1.7.1" :exclusions [[junit]]]
       [org.codehaus.plexus/plexus-interpolation "1.25"]
     [org.apache.maven/maven-model "3.6.1"]
     [org.apache.maven/maven-repository-metadata "3.6.1"]
     [org.codehaus.plexus/plexus-utils "3.2.0"]
     [org.slf4j/slf4j-api "1.7.25"]
 [cljfmt "0.7.0" :exclusions [[org.clojure/clojure]]]
   [com.googlecode.java-diff-utils/diffutils "1.3.0"]
   [org.clojure/tools.cli "1.0.194"]
   [rewrite-cljs "0.4.5"]
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [com.google.code.findbugs/jsr305 "3.0.2" :scope "provided" :exclusions [[org.clojure/clojure]]]
 [com.google.errorprone/error_prone_annotations "2.1.3" :scope "provided" :exclusions [[org.clojure/clojure]]]
 [commons-io "2.8.0" :scope "test" :exclusions [[org.clojure/clojure]]]
 [http-kit "2.5.1" :exclusions [[org.clojure/clojure]]]
 [nrepl "0.8.3" :exclusions [[org.clojure/clojure]]]
 [org.clojure/clojure "1.9.0" :scope "provided" :exclusions [[org.clojure/clojure]]]
   [org.clojure/core.specs.alpha "0.1.24" :scope "provided"]
   [org.clojure/spec.alpha "0.1.143" :scope "provided"]
 [org.clojure/clojurescript "1.10.520" :scope "test" :exclusions [[org.clojure/clojure]]]
   [com.cognitect/transit-clj "0.8.309" :scope "test" :exclusions [[org.clojure/clojure]]]
     [com.cognitect/transit-java "0.8.332" :scope "test"]
       [com.fasterxml.jackson.core/jackson-core "2.8.7" :scope "test"]
       [org.msgpack/msgpack "0.6.12" :scope "test"]
         [com.googlecode.json-simple/json-simple "1.1.1" :scope "test" :exclusions [[junit]]]
         [org.javassist/javassist "3.18.1-GA" :scope "test"]
   [com.google.javascript/closure-compiler-unshaded "v20180805" :scope "test"]
     [args4j "2.0.26" :scope "test"]
     [com.google.code.gson/gson "2.7" :scope "test"]
     [com.google.guava/guava "25.1-jre" :scope "test"]
       [com.google.j2objc/j2objc-annotations "1.1" :scope "test"]
       [org.checkerframework/checker-qual "2.0.0" :scope "test"]
       [org.codehaus.mojo/animal-sniffer-annotations "1.14" :scope "test"]
     [com.google.javascript/closure-compiler-externs "v20180805" :scope "test"]
     [com.google.jsinterop/jsinterop-annotations "1.0.0" :scope "test"]
     [com.google.protobuf/protobuf-java "3.0.2" :scope "test"]
   [org.clojure/google-closure-library "0.0-20170809-b9c14c6b" :scope "test"]
     [org.clojure/google-closure-library-third-party "0.0-20170809-b9c14c6b" :scope "test"]
   [org.mozilla/rhino "1.7R5" :scope "test"]
 [org.clojure/data.json "2.3.1" :exclusions [[org.clojure/clojure]]]
 [org.clojure/tools.analyzer.jvm "1.1.0" :exclusions [[org.clojure/clojure]]]
   [org.clojure/core.memoize "1.0.236"]
     [org.clojure/core.cache "1.0.207"]
       [org.clojure/data.priority-map "1.0.0"]
   [org.clojure/tools.analyzer "1.0.0"]
   [org.ow2.asm/asm "5.2"]
 [org.clojure/tools.namespace "1.1.0" :exclusions [[org.clojure/clojure] [org.clojure/tools.reader]]]
   [org.clojure/java.classpath "1.0.0"]
 [org.clojure/tools.reader "1.3.5" :exclusions [[org.clojure/clojure]]]
 [pjstadig/humane-test-output "0.8.1" :exclusions [[org.clojure/clojure]]]
 [rewrite-clj "0.6.1" :exclusions [[org.clojure/clojure]]]
 [version-clj "1.0.0" :exclusions [[org.clojure/clojure]]]

I tried just taking the suggestion of adding org.apache.httpcomponents/httpclient to the list of exclusions for pomegranate, but it then fails with a ClassNotFoundException (which would be expected if there only was one version of this dep).

What's going on here?

@vemv
Copy link
Member

vemv commented Jul 1, 2021

Yet locally I get no conflicting deps:

check out how :pedantic is set. You can use CI=true lein deps or maybe edit temporarily project.clj

I tried just taking the suggestion of adding org.apache.httpcomponents/httpclient to the list of exclusions for pomegranate, but it then fails with a ClassNotFoundException (which would be expected if there only was one version of this dep).

Yeah :pedantic doesn't always make an optimal suggestion. In this case, instead of an exclusion I'd add an explicit dependency on org.apache.httpcomponents/httpclient "4.5.9" (normally I pick the latest version when multiple are offered)


p.s. I self-assigned a couple issues from our tracker, I assume no overlap?

@expez
Copy link
Member Author

expez commented Jul 1, 2021

p.s. I self-assigned a couple issues from our tracker, I assume no overlap?

Yeah, just trying to figure out why the build is failing :)

@benedekfazekas
Copy link
Member

we don't really have a mranderson problem atm, do we?

@vemv
Copy link
Member

vemv commented Sep 17, 2021

(There's https://github.com/jafingerhut/dolly as well if anything else fails 😄, it's doing a decent job for Eastwood)

@expez
Copy link
Member Author

expez commented Sep 17, 2021

we don't really have a mranderson problem atm, do we?

When I start a REPL using the jar you published the REPL comes up without refactor-nrepl on the classpath. I can't see any errors anywhere so I've no idea what's wrong. The mrandersoned tests also run fine on the CI server. Pretty frustrating failure mode.

@benedekfazekas
Copy link
Member

When I start a REPL using the jar you published the REPL comes up without refactor-nrepl on the classpath. I can't see any errors anywhere so I've no idea what's wrong. The mrandersoned tests also run fine on the CI server. Pretty frustrating failure mode.

oh i see your comment above now. would be interesting to see the line how your REPL is started up, what is injected etc. there could be a problem there not with the actual jar

@expez
Copy link
Member Author

expez commented Sep 17, 2021

@benedekfazekas posted that too above, but here it is again:

[nREPL] Starting server via "c:/programdata/chocolatey/bin/lein.bat" update-in :dependencies conj ^"[nrepl/nrepl \^"0.8.3\^"]^" -- update-in :plugins conj ^"[refactor-nrepl/refactor-nrepl \^"3.0.0-pr301\^"]^" -- update-in :plugins conj ^"[cider/cider-nrepl \^"0.26.0-SNAPSHOT\^"]^" -- repl :headless :host localhost

@benedekfazekas
Copy link
Member

@benedekfazekas posted that too above, but here it is again:

[nREPL] Starting server via "c:/programdata/chocolatey/bin/lein.bat" update-in :dependencies conj ^"[nrepl/nrepl \^"0.8.3\^"]^" -- update-in :plugins conj ^"[refactor-nrepl/refactor-nrepl \^"3.0.0-pr301\^"]^" -- update-in :plugins conj ^"[cider/cider-nrepl \^"0.26.0-SNAPSHOT\^"]^" -- repl :headless :host localhost

you did, sorry. and it looks fine too. will check whats in that jar

@benedekfazekas
Copy link
Member

benedekfazekas commented Sep 17, 2021

only had time for a quick check now but doing this on a random project from CLI

$ clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-pr301"} cider/cider-nrepl {:mvn/version "0.25.9"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl

WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.orchard.v0v7v1.orchard.misc, being replaced by: #'refactor-nrepl.inlined-deps.orchard.v0v7v1.orchard.misc/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: refactor-nrepl.inlined-deps.orchard.v0v7v1.orchard.misc, being replaced by: #'refactor-nrepl.inlined-deps.orchard.v0v7v1.orchard.misc/update-keys
nREPL server started on port 62049 on host localhost - nrepl://localhost:62049

starts up the REPL fine. i might not be up to date on cider-nrepl etc...

@benedekfazekas
Copy link
Member

benedekfazekas commented Sep 19, 2021

I don't think there is a problem with 3.0.0-pr301 jar @expez

I jacked in with the following params:

;;  Startup: /usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta2"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-pr301"} cider/cider-nrepl {:mvn/version "0.26.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: cider.nrepl.inlined-deps.orchard.v0v7v1.orchard.misc, being replaced by: #'cider.nrepl.inlined-deps.orchard.v0v7v1.orchard.misc/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: cider.nrepl.inlined-deps.orchard.v0v7v1.orchard.misc, being replaced by: #'cider.nrepl.inlined-deps.orchard.v0v7v1.orchard.misc/update-keys
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.1 (package: 20210628.1154) and 3.0.0-pr301, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.passes, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-vals
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.passes.uniquify, being replaced by: #'refactor-nrepl.inlined-deps.toolsanalyzer.v1v0v0.clojure.tools.analyzer.utils/update-vals

and successfully run find-usages on my local machine. let me know if I missed anything here...

@expez
Copy link
Member Author

expez commented Sep 20, 2021

@benedekfazekas

On ubuntu 20.04, with openjdk 16.

$ clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta2"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-pr301"} cider/cider-nrepl {:mvn/version "0.26.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
Syntax error (FileNotFoundException) compiling at (refactor_nrepl/core.clj:1:1).
Could not locate clojure/tools/namespace/parse__init.class, clojure/tools/namespace/parse.clj or clojure/tools/namespace/parse.cljc on classpath.

I tested the equivalent command on win 10 with jdk8 and jdk 17 and got the same result.

@benedekfazekas
Copy link
Member

benedekfazekas commented Sep 20, 2021

this is what i see in the ns decl of refactor-nrepl.core:

(ns refactor-nrepl.core
  (:require [clojure.java.io :as io]
            [clojure.string :as str]
            [refactor-nrepl.inlined-deps.toolsnamespace.v1v1v0.clojure.tools.namespace.parse :as parse]
            [refactor-nrepl.inlined-deps.toolsreader.v1v3v5.clojure.tools.reader.reader-types :as readers]
            [refactor-nrepl.inlined-deps.orchard.v0v7v1.orchard.java.classpath :as cp]
            [refactor-nrepl.inlined-deps.orchard.v0v7v1.orchard.misc :as misc]
            [refactor-nrepl.inlined-deps.fs.v1v6v307.me.raynes.fs :as fs]
            [refactor-nrepl.util :as util :refer [normalize-to-unix-path]]
            [refactor-nrepl.s-expressions :as sexp]
            [refactor-nrepl.config :as config])
  (:import [java.io File FileReader PushbackReader StringReader]))

parse only occurs as an alias prefix in the body.

my only guess is that you tried to build the jar locally and it went wrong, or that there was a previous version of the same jar that was broken. maybe try to redownload the jar?

i am assuming my local repo jar is the one from clojars based on timestamps.
I've redownloaded the jar from clojars.

@expez
Copy link
Member Author

expez commented Sep 20, 2021

my only guess is that you tried to build the jar locally and it went wrong, or that there was a previous version of the same jar that was broken. maybe try to redownload the jar?

I hadn't built the jar locally and I've downloaded the jar on two different machines. I deleted it manually just to be sure one last time, with the same result.

I also tried building this branch locally, without inlining Pomegranate, and after installing the jar locally (under a different name 😛) I get a repl without any refactor-nrepl deps on the classpath again.

I must be doing something wrong, but I'm not sure what that is at this point. Maybe someone else can take this across the finish line...

@benedekfazekas
Copy link
Member

it is equally possible that i am doing something wrong but can't figure out what that would be... 😖 we are bit stuck here, i agree. @vemv @bbatsov any chance you can have a look if this jar does or does not work for you...

@bbatsov
Copy link
Member

bbatsov commented Sep 21, 2021

It works for me with JDK 14. I'll install and test 16 later.

@bbatsov
Copy link
Member

bbatsov commented Sep 21, 2021

Same with JDK 16. I ran:

$ clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta2"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-pr301"} cider/cider-nrepl {:mvn/version "0.26.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl

And then did a cider-connect. Everything worked fine.

@expez
Copy link
Member Author

expez commented Sep 21, 2021

Thanks for testing @bbatsov.

I still can't get a REPL going in emacs, but connecting to this:

$ clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta2"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-pr301"} cider/cider-nrepl {:mvn/version "0.26.0"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl

does work, if I don't do it in the context of the refactor-nrepl project.

  • pomegate works as it should on Java 16 (tested at the REPL).
  • hotload-deps in the 3.0.0-pr301 artifact fails with The super POM /refactornrepl300pr301/org/apache/maven/model/pom-4.0.0.xml was not found, please verify the integrity of your Maven installation during dependency resolution
  • I tried building a jar from this branch without pomegranate as an inlined dep (using lein do clean, inline-deps && lein with-profile +plugin.mranderson/config install) but that gives me a jar without pomegranate in it which obv fails when hotload-deps is called

Might spend some more time on this tomorrow, but kind of stuck again. The dependency resolution fails deep int the java code of the maven-resolver AFAICT.

expez and others added 6 commits September 23, 2021 13:35
Previously this op was built on top of alembic, but that lib no longer
seems to be maintained at all so we're moving to pomegranate.

`tools.deps` would've been another alternative by their `add-lib`
operation has yet to be merged to the main branch.  Once it's merged and
has proven itself in the wild nothing prevents us from moving over,
though, if that solution proves to be better in some way.
as a workaround for the error that happens when inlining
dependencies. this way javax.* packages won't get prefixed
`get-clojars-versions` threw a different exception than expected so it
made sense to return nil when nothing found so the expected IAE would
be thrown
@expez
Copy link
Member Author

expez commented Sep 23, 2021

I was at a bit of a loss as to how I could make pomegranate work so I decided to give add-libs a try instead.

I got it working at the REPL, but after packaging it up it fails because mranderson doesn't handle these loads

;; Load extensions
(load "/clojure/tools/deps/alpha/extensions/maven")
(load "/clojure/tools/deps/alpha/extensions/local")
(load "/clojure/tools/deps/alpha/extensions/git")
(load "/clojure/tools/deps/alpha/extensions/deps")
(load "/clojure/tools/deps/alpha/extensions/pom")

Because e.g. the maven extension is now called refactor-nrepl.inlined-deps.toolsdepsalpha.v0v12v1048.clojure.tools.deps.alpha.extensions.maven

Since the add-libs code is unreleased and lives on its branch I opted to just include it in our jar. Initially I wanted to preserve the namespace but when I stored it under src/clojure/tools/deps/alpha/repl.clj mranderson didn't pick it up, so I moved it where it is now 🤷

Oh, and I also had to edit one line in add-libs to make it work with projects that are leiningen based. This probably means that projects that aren't tools.deps based will be less robust to weird edge-cases, but given the intended use-case I think that's OK.

It'll probably be a week or two until I have time to look at this again 😞

If anyone wants to pick up the torch, feel free to push directly to this branch,

@abcdw
Copy link

abcdw commented Oct 25, 2022

Hi everyone! Are there any updates on this topic?

@expez
Copy link
Member Author

expez commented Oct 25, 2022

Are there any updates on this topic?

Nope. I've had no time to work on this. IIRC I ran into some problems with mranderson that I was unable to solve. tools.deps pulls in a huge amount of java deps, so it's not entirely surprising that we ran into some edge-cases when doing code rewriting.

I believe this feature is sorely missed, so if you want to get involved that would be most welcome!

@expez expez closed this Oct 25, 2022
@vemv
Copy link
Member

vemv commented Oct 25, 2022

It's also a pretty difficult problem to solve in general - I'd wager that once we would get past mranderson issues we'd get into a new world of JDK/classpath issues 😄

We can always wait for other libs to solve it and eventually integrate those.

@plexus
Copy link
Contributor

plexus commented Oct 26, 2022

For what it's worth we've taken a new take on hot reloading of dependencies with lambdaisland/classpath, and expanded on it in launchpad. This will watch deps.edn for changes, as well as the deps.edn of any projects linked with :local/root. It works by leveraging tools.deps, and injecting a custom classloader which can "override" entries from the classpath the system started with.

Not saying it's flawless, as mentioned there are a lot of tricky edge cases because a lot of JVM stuff doesn't expect you to mess with the classpath mid-flight. E.g. adding ClojureScript libs still requires a restart. But it's been working pretty well for us.

I also did a blog posts about this stuff. It's hairy: The Classpath is a lie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants