Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can no longer jack-in to an inherited clojure version #1824

Closed
jimrthy opened this issue Aug 13, 2016 · 11 comments
Closed

Can no longer jack-in to an inherited clojure version #1824

jimrthy opened this issue Aug 13, 2016 · 11 comments

Comments

@jimrthy
Copy link

jimrthy commented Aug 13, 2016

Expected behavior

Under 0.12.0 (and earlier), I could specify the clojure version in one library and then have other libraries/apps that depend on that one so I don't have to keep all the common library versions updated in various projects that use them.

This still seems to work fine under lein repl.

Actual behavior

cider-jack-in results in a stack trace that basically starts with an error about nrepl-server-sentinel and "cider.nrepl.middleware.version: Too many arguments to def."

There are a bunch of "Unable to resolve symbol: some-> in this context" java.lang.Exceptions.

And then it ends with a "java.lang.Exception: Unable to resolve symbol: some? in this context."
The full stack trace is available at https://github.com/jimrthy/clojure-introduction/blob/cider/transitive-clojure-version/cider-transitive-version/README.md

Steps to reproduce the problem

  • git clone https://github.com/jimrthy/clojure-introduction
  • git checkout cider/transitive-clojure-version
  • cd cider-transitive-version
  • lein install
  • cd ../usage
  • lein deps :tree
  • Verify that it inherits org.clojure.clojure 1.9.0-alpha10 from cider-transitive-version
  • Verify that lein repl starts correctly (I seem to be able to cider-connect to this, so I think I have a work-around)
  • Try to cider-jack-in to the usage project, see the stack trace
  • Uncomment the clojure dependency in usage/project.clj
  • Verify that cider-jack-in works correctly

Environment & Version information

CIDER version information

CIDER 0.13.0 (California), nREPL 0.2.12
Clojure 1.9.0-alpha10, Java 1.7.0_79

Lein version

2.6.1

Emacs version

GNU Emacs 24.3.1 (x86_64-px-linux-gnu, GTK+ Version 3.10.7) of 2014-03-07 on lamiak, modified by Debian

Operating system

Ubuntu 14.04.3 LTS

@bbatsov
Copy link
Member

bbatsov commented Aug 20, 2016

@benedekfazekas can you check this?

@benedekfazekas
Copy link
Member

had a look. Don't quite understand the reason behind this yet. What I can see that if I set (setq cider-inject-dependencies-at-jack-in nil) and edit ~/.lein/profiles.clj the "old" way: eg add cider deps to the :repl profile there then it works fine.

Pinged a question to the leiningen devs about this as well.

@jimrthy
I guess a couple of things worth investigating if you are willing:

  • boot. autinjecting the deps for cider works quite differently in boot I suppose than in leiningen.
  • the new leiningen feature managed-dependencies could be used to achieve what you want here. it needs an additional lein plugin tho: see manage deps doc for details -- please note that I have not tested this with cider yet

@hypirion
Copy link

I did the steps until cd ../usage and then replaced the lein deps :tree with the result of update-in:

$ lein update-in :dependencies conj '[org.clojure/tools.nrepl "0.2.12"]' -- deps :tree
Possibly confusing dependencies found:
[org.clojure/tools.nrepl "0.2.12"]
 overrides
[org.clojure/tools.nrepl "0.2.12" :exclusions [org.clojure/clojure]]

Consider using these exclusions:


[org.clojure/tools.nrepl "0.2.12"] -> [org.clojure/clojure "1.2.0"]
 overrides
[cider-transitive-version "0.1.0-SNAPSHOT"] -> [org.clojure/clojure "1.9.0-alpha10"]

Consider using these exclusions:
[cider-transitive-version "0.1.0-SNAPSHOT" :exclusions [org.clojure/clojure]]

 [cider-transitive-version "0.1.0-SNAPSHOT"]
 [clojure-complete "0.2.4" :exclusions [[org.clojure/clojure]]]
 [org.clojure/tools.nrepl "0.2.12"]
   [org.clojure/clojure "1.2.0"]

The first confusing dependency can be ignored, but note that, since tools.nrepl doesn't specify an exclusion, the clojure dependency used by tools.nrepl overrides the transitive dependency from cider-transitive-version. A good solution would be to inject [org.clojure/tools.nrepl "0.2.12" :exclusions [[org.clojure/clojure]]] instead, if that's possible.

@benedekfazekas
Copy link
Member

I think I tried to inject tools.nrepl with that exclusion see my comment on #1665

But this was a long time ago so don't quite recall the details. I shall try again.

@hypirion
Copy link

It won't fix #1665 unfortunately (the proper fix there is technomancy/leiningen#2074), but it will at least resolve this issue.

@jimrthy
Copy link
Author

jimrthy commented Sep 5, 2016

It looks like the tools.nrepl injection is definitely the culprit.

Adding (setq cider-inject-dependencies-at-jack-in nil) to my .emacs.d seems like a perfectly valid work-around.

I didn't have any luck figuring out how to inject a version of tools.nrepl with that exclusion to override the one that cider injects.

Managed dependencies is the Right Thing(TM) for what I'm doing anyway. It seemed to work fine with CIDER. Thanks for pointing it out!

I'll be happy convert the example to boot (I've been meaning to play with it anyway) to see what happens, but I doubt I'll have a chance tonight.

It seems like it might be worth documenting the work-arounds somewhere (maybe in the same caveat that mentions #1665 ?), but this seems ready to close to me.

Thanks for such a wonderful tool!

@benedekfazekas
Copy link
Member

It looks like the tools.nrepl injection is definitely the culprit.

you're (and hyPiRion is) right. I am working on a fix for this atm.

Managed dependencies is the Right Thing(TM) for what I'm doing anyway. It seemed to work fine with CIDER. Thanks for pointing it out!

nice one! would love to see a working example if it is public and you can share.

I'll be happy convert the example to boot (I've been meaning to play with it anyway) to see what happens, but I doubt I'll have a chance tonight.

would be very helpful, yes please. it seems that current stable boot release does not have support for defining exclusions on the command line but the their master already has such an option! So you migrating your example to boot would enable me to test my patch for boot too using their master.

It seems like it might be worth documenting the work-arounds somewhere (maybe in the same caveat that mentions #1665 ?), but this seems ready to close to me.

as i am working on a fix this won't be necessary.

benedekfazekas added a commit that referenced this issue Sep 5, 2016
Add option to define exclusions for injected dependecies. Add
`org.cloure/clojure` exclusion to `org.clojure/tools.nrepl` to mitigate
problem with tools.nrepl clojure dependency.

Note about boot: the latest stable release does not support defining
depedency exclusions on the command line. However, this feature is
available in the upcoming 2.7.x release. This feature will be added
for boot when 2.7.x is released.
benedekfazekas added a commit that referenced this issue Sep 8, 2016
Add option to define exclusions for injected dependecies. Add
`org.cloure/clojure` exclusion to `org.clojure/tools.nrepl` to mitigate
problem with tools.nrepl clojure dependency.

Note about boot: the latest stable release does not support defining
depedency exclusions on the command line. However, this feature is
available in the upcoming 2.7.x release. This feature will be added
for boot when 2.7.x is released.
@jimrthy
Copy link
Author

jimrthy commented Sep 10, 2016

Sorry about the delay.

https://github.com/jimrthy/clojure-introduction/tree/cider/broken-transitive-versions has the original problem example.

https://github.com/jimrthy/clojure-introduction/tree/cider/transitive-clojure-version switches it to use lein's managed-dependencies.

https://github.com/jimrthy/clojure-introduction/tree/cider/transitive-boot converts it to boot, which seems to work fine.

https://github.com/jimrthy/frereth-client is the real-world project where I first saw the problem. It (along with a couple of others, which is the point) should get a bunch of library dependencies from https://github.com/jimrthy/frereth-common. I'm not sure what kind of state either's in. The past week has been pretty frantic.

Thanks again!

@benedekfazekas
Copy link
Member

thanks for the work around this @jimrthy. I will defo check out your boot example.

There is also a PR going on to fix this for lein (#1844) which is ready from my part I think it is up to @bbatsov or/and @Malabarba to say yeah/nay.

@benedekfazekas
Copy link
Member

@jimrthy as you see this got merged so should be fine with leiningen now.

re. managed dependencies: checked it out (being curious) looks cool. thx for putting it together.

re. boot. it does work but both from cider and from CLI i get a repl with clojure 1.7.0. is not that a problem?

@jimrthy
Copy link
Author

jimrthy commented Sep 16, 2016

Thanks very much!

You're absolutely right about the version under boot. Until it works through their REPL, I don't think we can expect it to work with CIDER. :-)

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

No branches or pull requests

4 participants