clojure-emacs / clj-refactor.el

A CIDER extension that provides powerful commands for refactoring Clojure code.
GNU General Public License v3.0
773 stars 111 forks source link

cljr-update-project-dependencies deps.edn not updating packages complains about not being jacked in. #460

Closed olymk2 closed 3 years ago

olymk2 commented 4 years ago

Expected behavior

when running cljr-update-project-dependencies cljr should ask to update dependencies.

Actual behavior

cljr navigates to deps.edn it returns a message saying cider is not jacked in, however I am connected and can evaluate in any cljs file so definitely jacked in.

note I had to remove project.clj perhaps putting deps.edn before project.clj in the code is a good idea ? as project.clj can use deps.edn via a plugin.

Steps to reproduce the problem

local clojurescript project with deps.edn and no projec.clj file jack in and call cljr-update-project-dependencies.

Environment & Version information

clj-refactor.el version information

clj-refactor 2.5.0-SNAPSHOT, refactor-nrepl is unreachable

CIDER version information

;; CIDER 0.24.0snapshot, nREPL 0.6.0
;; Clojure 1.10.0, Java 11.0.5

Leiningen or Boot version

using clj and deps.edn

Emacs version

GNU Emacs 26.3 (build 1, x86_64-solus-linux-gnu, GTK+ Version 3.24.11) of 2019-10-05

Operating system

solus 4.1

prestancedesign commented 4 years ago

cljr navigates to deps.edn it returns a message saying cider is not jacked in, however I am connected and can evaluate in any cljs file so definitely jacked in.

Maybe you had only CLJS REPL. Can you try to jack-in in both REPL (clj & cljs) ?

image

olymk2 commented 4 years ago

I was using the other jack in tried with clj & cljs however and hit the same issue, it opens the project.clj file instead of the deps.edn file and does not start updating any packages.

prestancedesign commented 4 years ago

Do you have tried if it works with a basic template?

clj -Sdeps '{:deps
              {seancorfield/clj-new
                {:mvn/version "0.9.0"}}}' \
  -m clj-new.create \
  app \
  hello/world

Delete/rename the pom.xml file at root directory before cljr-update-project-dependencies.

olymk2 commented 4 years ago

so the above works, the differences I can see are that the hello world app is clojure and not clojure script and the presence of a project.clj also causes issues.

Adding this to the root means the deps file no longer updates.

(defproject hello.world "0.1.0-SNAPSHOT"
  :uberjar-name "server.jar"
  :target-path "target/%s"
  :source-paths ["src" "src/clj" "src/cljs"]
  :ring {:handler server-rendering.handler/app}
  :plugins [[lein-tools-deps "0.4.5"] [lein-ring "0.12.5"]]
  :middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn]
  :lein-tools-deps/config {:config-files [:install :user :project]})

how ever on a clojurescript project with out a project.clj file I just get the CIDER is not connected error even though I am connected and can eval inside emacs.

anything else you would like me to try ?

prestancedesign commented 4 years ago

anything else you would like me to try ?

Yes, next step you can try a Clojurescript template:

clj -Sdeps '{:deps{seancorfield/clj-new {:mvn/version "0.9.0"}}}'d -m clj-new.create figwheel-main hello-world.core -- --reagent

Then:

olymk2 commented 4 years ago

that also works, fails with project.clj again and i noticed this in the messages buffer.

image

I will look at difference between this and another project to see if i can figure out why its not working in my other projects

olymk2 commented 4 years ago

okay my bad I tried again and it seems to have worked must have been working on auto pilot with jack in cljs, is there a reason it would work with one and not the other ?

thanks for the help, i guess the project file may still be an issue anyway separate to the dep not updating at all issue.

prestancedesign commented 4 years ago

Another idea. In your project, you can try the sesman-browser command after jack-in to check if clj REPL is running. Maybe your the CLJS REPL start but the CLJ failing for some reasons (wrong config, etc).

olymk2 commented 4 years ago

should clj always exist even when using a cljs only project ? I always check the repl but usually I only have a cljs repl because I am working on cljs only projects, I do check they are connected.

what is wierd is the clj+cljs shows 2 clj repls not a clj and cljs repl.

image

you can also see the connection to the other project which is currently a cljs repl only.

prestancedesign commented 4 years ago

should clj always exist even when using a cljs only project ?

AFAIK to use some commands of clj-refactor, yes.

what is wierd is the clj+cljs shows 2 clj repls not a clj and cljs repl.

It's because your REPL Figwheel failed higher then fallback to CLJ REPL I guess. With Cider for running figwheel-main template, we must edit the REPL command with manually adding -A:fig.

image

expez commented 3 years ago

Thanks for your help on this @prestancedesign!

If this shows up again, maybe there's something we can do on our end to prevent this from happening.