-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
Cider should inject its own dependencies/plugins automatically at cider-jack-in #1531
Comments
I've been thinking along the same lines (for clj-refactor as well) lately so +1 also we should be able to figure out if given setup uses lein or boot |
+1 for this, don't want to continuously monitor version change update. |
I mentioned this on slack. I'll be glad to provide this if lein (or boot) has a way to specify deps on the command line. Otherwise it would involve manually parsing the project.clj file in elisp, which is not something I'm super excited to do. =) One thing that would be easier to do is to offer a "new project" command, which would create the project with the right deps. However, this wouldn't solve any of the complaints here. |
I've been thinking about it -- a "cider shim" plugin which pulls the middleware into the JVM with pomegranate really seems possible to me. It should be possible to write it once and rarely update it. I guess it needs to inject both into the repl and the leiningen JVM? I've been watching a new colleague of mine trying to install cider, and this step really isn't nice. |
We do something like this in refactor-nrepl eg. add dependency to a running REPL. My worry is tho that these artifacts are not simple deps but nrepl middlewares there could be some extra steps to register them. No idea if this works dynamically. |
I think it works. Can someone give this a go: https://github.com/phillord/plugin-inject You launch with Might not work for anyone else, but seems a reasonable start. It's only a few lines of code. |
@phillord do you think it would be possible to specify the version of the cider middleware? |
Hmmm, think I've made a mistake. I had an old "cider-nrepl" dependency left in my .lein. So, it's not working. Try again. I think more generally this is a leiningen issue -- if cider could specify it's own profile.clj which was merged with the users, this would solve the problem. A shim is a bit of a cheap plastic solution (bad pun). |
It might be easier to just check if I don't think we need more indirection (a shim) or any magic happening in the background (injecting the right stuff into a running repl). |
I don't think would help with the new install. I agree, the shim is rather complex. Having support in lein would be the easiest. |
this seems to be working for me:
|
it seems to me that boot has even better support for this via their |
more on leiningen: in fact it is doable even now with setting so I guess we could introduce a variable listing all nrepl middleware plugins (so clj-refactor can add its own) and then update those in as plugins by default with perhaps an opt out config in case somebody wants to start up cider without this. |
Nice! If it's as simple as that, I'd like to start using this as soon as the next release. |
It looks like so. I just removed my
And started cider on a test clojure project. Bingo, all works. The command line is a bit of a gobsmacker, and probably doesn't need to get displayed to the user, but that's just a matter of adding a new variable. @benedekfazekas Thanks! I hadn't seen the update-in task. |
no worries. will try to have a look on boot as well. not sure we need to handle |
Boot can be handled with a custom task -- like the "cider repl" task in the doc, but passing in version numbers as keys. This has been a PITA ever since the middleware came in, so removing the hassle for new users is going to be a major contribution to useability. And it should cleanly update from version to version. |
after having a chat with @micha on slack it seems there is CLI way for boot too, something like: |
With boot, I put this into my boot.profile
Added this into a clean emacs, with cider installed.
Loaded a new project, and it works. It could be made more generic still, I guess --- have a task which loads a file inside CIDER which defines the task -- which would secure against any changes in boot or if more middlewares are needed. I'm very happy! I rather not regret putting this up as an issue a while back now, as the problem to have been solved more straight-forwardly than I would have guessed. |
yup this is nice but we still need the user to define this task or hide it somewhere in the elisp code of cider or something. would be even nicer to: |
INdeed, if we have to tell users to define that task, then we haven't gained much on the boot front. It'd be nicer to do it all directly. |
the boot guys discussing the scenario when you connect to a running repl process which apparently is how quite a few ppl prefer to work even with emacs (instead of jack-in). for that case finding a way to add the middleware at run time would still have good value. but I suppose solving this at start up for the |
@Malabarba with that task you would at least have gained version independence, so it would be worth documenting anyway. So long as cider's dependency requirements are accessible from lisp, then it can be made to work anyway of course. Still, agree it's suboptimal. Surprised to find boot doesn't have an "eval" or "load-file" task, a la emacs --batch. Would solve the problem |
I think that's a slightly more advanced task, so people who understand how that works should have no problems following the readme.
True. If there's no better alternative, we should document it. 👍 |
@benedekfazekas if you are already talking to the boot guys, want to ask whether they will add a eval or load-file task? It's generic, totally future proof and, sometimes, only lambda is enough:-) |
@phillord why would that be beneficial? It seems that we can do the same (or very similar) with boot on the CLI as with lein at start up time -- see my comment above. So the ux would be the same for both lein and boot when jacking in without any extra config done by the user. Btw thanks a lot for raising this! |
@benedekfazekas Oh, I couldn't get that to work; sorry, should have said. Is there a -m option command line option? |
There is, yes, for the repl task. So you will only see it if you run help for the repl task. Will have a play with it when I have a little time. |
@benedekfazekas Right you are.
This seems to do the trick on a clean emacs. |
Awesome 👍 thx for figuring it out |
i might try to put together a PR for this tmrw if nobody else is already working on it in anger. let me know |
I am not at the moment, and will not get to it for tomorrow or the next few days, so please go ahead. |
I'm also not working on it. Feel free to go ahead. |
[wip] so users don't have to fiddle with profiles.clj and the like, see details in clojure-emacs#1531 supports leiningen and boot
[wip] so users don't have to fiddle with profiles.clj and the like, see details in clojure-emacs#1531 supports leiningen and boot
So users don't have to fiddle with profiles.clj and the like, see details in clojure-emacs#1531 Supports both leiningen and boot. Additionally there is a defcustom `cider-skip-repl-dependencies-at-jack-in` to switch this functionality off (defaults to nil); and an extension point defun (`cider-add-repl-dependencies`) so other tools like clj-refactor can inject to their own dependencies, middlewares Fix clojure-emacs#1531 and clojure-emacs#1534
So users don't have to fiddle with profiles.clj and the like, see details in clojure-emacs#1531 Supports both leiningen and boot. Additionally there is a defcustom `cider-inject-dependencies-at-jack-in` to control this functionality (defaults to t); and an extension point (`cider-add-repl-dependencies`) so other tools like clj-refactor can inject to their own dependencies, middlewares. Fix clojure-emacs#1531 and clojure-emacs#1534
So users don't have to fiddle with profiles.clj and the like, see details in clojure-emacs#1531 Supports both leiningen and boot. Additionally there is a defcustom `cider-inject-dependencies-at-jack-in` to control this functionality (defaults to t); other tools (like clj-refactor) can modify `cider-jack-in-dependencies`, `cider-jack-in-lein-plugins` and `cider-jack-in-nrepl-middlewares` to inject their own dependencies. Fix clojure-emacs#1531, clojure-emacs#1534
So users don't have to fiddle with profiles.clj and the like, see details in clojure-emacs#1531 Supports both leiningen and boot. Additionally there is a defcustom `cider-inject-dependencies-at-jack-in` to control this functionality (defaults to t); other tools (like clj-refactor) can modify `cider-jack-in-dependencies`, `cider-jack-in-lein-plugins` and `cider-jack-in-nrepl-middlewares` to inject their own dependencies. Fix clojure-emacs#1531, clojure-emacs#1534
So users don't have to fiddle with profiles.clj and the like, see details in clojure-emacs#1531 Supports both leiningen and boot. Additionally there is a defcustom `cider-inject-dependencies-at-jack-in` to control this functionality (defaults to t); other tools (like clj-refactor) can modify `cider-jack-in-dependencies`, `cider-jack-in-lein-plugins` and `cider-jack-in-nrepl-middlewares` to inject their own dependencies. Fix clojure-emacs#1531, clojure-emacs#1534
So users don't have to fiddle with profiles.clj and the like, see details in clojure-emacs#1531 Supports both leiningen and boot. Additionally there is a defcustom `cider-inject-dependencies-at-jack-in` to control this functionality (defaults to t); other tools (like clj-refactor) can modify `cider-jack-in-dependencies`, `cider-jack-in-lein-plugins` and `cider-jack-in-nrepl-middlewares` to inject their own dependencies. Fix clojure-emacs#1531, clojure-emacs#1534
Currently, cider complains when the dependencies are wrong in profile.clj. I understand the reasons for this, but it would be nice if Cider offered the ability to update your profile for you.
Another possibility would be for cider to check whether pomegranate is present and if not, inject the correct dependencies. Don't know if that is possible with plugins, but worth thinking about.
This would be great for me when I am switching Emacs' -- sometimes using melpa-stable, sometimes melpa normal. Then I have to continually re-edit my profile.clj. Painful.
The text was updated successfully, but these errors were encountered: