cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Can't Enable Profiles in Leiningen Project on WSL/Ubuntu 22.04

Open 64BitChris opened this issue 11 months ago • 29 comments

Using WSL2 with Ubuntu 22.04 - IDEA 2023.3.5.

Cursive 1.13.1-2023.3.

I loaded a project from the project.clj file. Cursive appears to pull in the following profiles on initial project start: base, dev, provided, system, and user.

When selecting any other profile and clicking the refresh icon, I receive the following notification:

Error resolving dependencies for xx.yy/zz:0.1.0-SNAPSHOT

void org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManager. (java.io.File, org.eclipse.aether.RepositorySystemSession)'

Then, the newly selected profile goes back to unchecked.

There is nothing of note in the IDEA log file.

This makes it very difficult for Cursive to work with multi-profile projects in Clojure and WSL. I've reloaded Windows and replicated this on two different machines. I need profiles to work, or else I'll have to learn how to use Calva/VS Code (which I don't want to do as I've been a forever supporter and fan of Cursive, but this is super frustrating).

64BitChris avatar Mar 15 '24 18:03 64BitChris

Hmm, that's strange, I'll try to reproduce this in a Windows VM and see if I can see it there.

cursive-ide avatar Mar 15 '24 20:03 cursive-ide

Thanks!

A couple of things I've learned while trying to fix this:

This function signature was last seen in the Maven Artifact Resolver Implementation, v 1.6.3

https://mvnrepository.com/artifact/org.apache.maven.resolver/maven-resolver-impl/1.6.3

I downloaded this JAR and verified the presence with:

javap -classpath /mnt/c/Users/chris/Downloads/maven-resolver-impl-1.6.3.jar -c org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManager | grep Enhanced

which gave me this:

class org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManager extends org.eclipse.aether.internal.impl.SimpleLocalRepositoryManager {
  org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManager(java.io.File, org.eclipse.aether.RepositorySystemSession);

I've placed this jar into the cursive-plugin/lib directory inside of clojure-plugin.jar but that didn't have any impact. I'm currently trying to put it in on the IDEA classpath but that is more difficult than it used to be, especially given the Host/Client/Gateway configs (ie IDK where to put it).

64BitChris avatar Mar 15 '24 20:03 64BitChris

I reinstalled IntelliJ again - and my first load of my project still had the same problem (enabling a profile didn't work and became unchecked after a couple of seconds) but did not pop up the error in the notification panel.

I went into the Leiningen settings and changed it from 2.10.0 -> Latest (2.11.2) and then hit refresh. That caused the Notification to pop up with the error originally specified.

At the command line, I can run leiningen (Leiningen 2.11.2 on Java 21.0.2 OpenJDK 64-Bit Server VM) commands in this project with an enabled profile and things appear to be working properly at the CLI on the Ubuntu system.

64BitChris avatar Mar 15 '24 21:03 64BitChris

I put the 1.6.3 version of the resolver on the IDEA classpath (/home/chris/.cache/JetBrains/RemoteDev/dist/f21177b3c7b09_ideaIU-2023.3.5/plugins/maven/lib/maven3/lib/maven-resolver-impl-1.6.3.jar)

and that had no effect. Looks like IDEA ships with 1.9.16 (which does not have this missing signature) but I guess the leiningen CP in IDEA must be different or isolated from the main IDEA.

Any other ideas of where I can put this library so that it can be viewed by Leiningen running inside Cursive?

64BitChris avatar Mar 15 '24 21:03 64BitChris

No, I don't think there's any way to do that, sorry. The issue is that Lein recently updated the version of the Maven Resolver they bundle, and that now provokes a conflict in Cursive with the version that IntelliJ provides. I fixed a related problem recently (#2879), but there must be another case I didn't catch. I wonder if it's Windows-specific somehow. I can't look at it today sorry, but will try to tomorrow.

cursive-ide avatar Mar 16 '24 00:03 cursive-ide

BTW do you need lein 2.11.2 for some reason? Can you use 2.10.0 in the meantime?

cursive-ide avatar Mar 16 '24 00:03 cursive-ide

BTW do you need lein 2.11.2 for some reason? Can you use 2.10.0 in the meantime?

When I try 2.10.0 and 2.9.5 (the oldest release listed), I still can't enable a profile. I click the checkbox, it looks like it is doing something (in the background bar) and then the checkbox becomes unchecked and the dependency list has not been updated or changed. Nothing of note in the log either (do you know where I should be able to see this exception logged?).

None of the Leiningen versions allow me to enable profiles.

To eliminate anything I might be doing in my project, I cloned https://github.com/ring-clojure/ring.git and tried enabling the codox profile. Same behavior - in 2.11.2 I can't refresh without the exception. In 2.10.0 and below, I can refresh (without a popup exception), but I can't enable profiles (they become unchecked).

Thanks for your help, by the way. Please let me know if there's anything else I can try.

64BitChris avatar Mar 16 '24 02:03 64BitChris

As an aside, I was trying to install the EAPs on Cursive to see if your changed for lein 2.11 would make a difference. I tried on both 2023.3.5 and 2024.1 Beta and I couldn't get the EAP version of the plugin to installed (tried eap4 and eap7 - both for the respective version of IDE). Both gave me this error about requiring com.intellij.modules.java

image

64BitChris avatar Mar 16 '24 03:03 64BitChris

That is really weird. I'd be interested to know if the EAP worked better for you too - I have no idea why you wouldn't be able to select profiles. And it's really weird that you don't have Java installed in your IntelliJ, as far as I know you can't uninstall or disable that, so I have no idea what that message might mean. I'll ask JetBrains, although they probably won't answer until next week now.

If you go to https://plugins.jetbrains.com/plugin/8090-cursive/edit/versions/eap and download the EAP version corresponding to your IDE version, does it let you install it with the "Install Plugin from Disk" action?

cursive-ide avatar Mar 16 '24 08:03 cursive-ide

Actually, looking back at it, your original problem is actually the same as #2879, so hopefully the EAP should fix that one if we can figure out how to get it installed.

cursive-ide avatar Mar 16 '24 08:03 cursive-ide

If you go to https://plugins.jetbrains.com/plugin/8090-cursive/edit/versions/eap and download the EAP version corresponding to your IDE version, does it let you install it with the "Install Plugin from Disk" action?

Yes, it was the only way I could install the EAP in both 2023 and 2024 (I don't know where the toggle is to enable Cursive EAPs in IDEA). Weirdly, both times I installed it from disk, it said it was verifying required dependencies and never complained a single time. But upon reboot this error is there and the plugin won't startup.

I'm going to try uninstalling, removing caches, and installing 2024 again with the eap 7. If that doesn't work I'm gonna try out deps.edn support in Cursive and going to hope that resolves problems. Seems like people like deps more than lein these days for some things. Would you recommend that as well?

64BitChris avatar Mar 16 '24 15:03 64BitChris

EAP toggle is here: https://cursive-ide.com/userguide/#choosing-to-receive-eap-beta-builds

This can also be a gotcha: https://cursive-ide.com/userguide/troubleshooting.html#cursive-on-intellij-eap-builds

Deps is a different beast to lein, and whether you like it more or not is mostly a matter of taste. I tend to use it by default these days, and I think the deps support in Cursive is more stable just because deps is much simpler than lein (there have still been problems though, of course, build system support is just complicated). I find the command line syntax of deps maddeningly confusing though, there's definitely a hump to get over there. You might find something like neil helpful: https://github.com/babashka/neil.

That said, I'd really like to figure out what is going on for your setup. I think the original lein problem should be fixed by the EAP, and I'm hoping to get that into a stable build in the next day or two, barring any terrible issues. I'll ask JetBrains why they think that java module error might be appearing.

cursive-ide avatar Mar 16 '24 19:03 cursive-ide

Thanks for the instructions.

I was able to install the EAP on 2023.3.5, and I can confirm that the exception no longer appears in the Notification panel.

However, I still can not enable a profile. The behavior is now that I check a box next to a profile, click refresh, and then a couple of seconds later, the box becomes unchecked again, with no update to the dependency lists.

idea.log doesn't contain anything of note.

64BitChris avatar Mar 17 '24 02:03 64BitChris

Additionally, installing via the IDE with the EAP toggle enabled (using 'Update' in the Plugins Marketplace) did not yield the Java plugin error.

I received the java plugin error when I tried installing the plugins, downloaded from the repository directly, using the 'install plugin from disk' option.

64BitChris avatar Mar 17 '24 02:03 64BitChris

Unfortunately, I have bad news; the behavior seems to be the same with deps projects as well.

I tried working with this deps project:

https://github.com/seancorfield/dot-clojure

I cannot enable aliases with 2023.3.5 and eap7, seems like it's the same behavior as with a leiningen project.

Nothing appears in the log, my dependencies don't change, and the checkbox returns to being unchecked upon a refresh.

Here's a video capture of what I'm seeing (there is sound):

https://github.com/cursive-ide/cursive/assets/1381061/0bf7c613-41c2-41d6-b168-55539fe5d6f2

64BitChris avatar Mar 17 '24 19:03 64BitChris

Hmm, that's actually potentially good news, since it means there's nothing untoward with the lein integration, which could be anywhere from awkward to terrifying.

No-one else has reported anything like this, so I'm wondering if it's something with your setup. It sounds to me like IntelliJ can't persist its settings for some reason. Just to clarify, are you actually running IntelliJ inside WSL, i.e. in the Linux environment? Or is it running in Windows?

cursive-ide avatar Mar 18 '24 02:03 cursive-ide

No-one else has reported anything like this, so I'm wondering if it's something with your setup. It sounds to me like IntelliJ can't persist its settings for some reason. Just to clarify, are you actually running IntelliJ inside WSL, i.e. in the Linux environment? Or is it running in Windows?

I'm not super clear on the architecture, but I believe it's something like this:

  • On the WSL, Ubuntu 22.04, a running version of IDEA gets started - this is the 'HOST' I believe
  • There is a thin client that runs on Windows 11 which I believe is displaying the UI for the IDE running on the WSL Host.
  • There's something called the IDEA Gateway that is communicating between the client (windows 11) and the host (WSL Ubuntu 22.04).

Something of note is that when you go to the plugin page for the Cursive plugin and look at the versions, depending on how you get to that page, it will tell you that Cursive is not compatible with the IDEA Gateway - so I'm not sure if that is it or not. Maybe something there is missing for changing these settings.

I'm not sure why other people don't have this problem - perhaps they're developing on Windows natively, or using VS Code (where WSL works so well that sometimes I don't realize I'm working in the WSL environment>. Or maybe most Clojure people use macs or linux - IDK :-)

64BitChris avatar Mar 19 '24 16:03 64BitChris

I thought I was losing my mind, I've been having this same problem on WSL2 and Windows 11 pro. is there any update on this?

MikeMcMahon avatar Mar 27 '24 14:03 MikeMcMahon

There isn't unfortunately, I've been busy working on some other things I have to get done ahead of the 2024.1 release. But this is the next thing I'll look at after that. It's tricky for me to reproduce since I don't have a Windows machine, so I'll be setting up WSL2 inside Parallels inside my mac, which gets pretty meta...

cursive-ide avatar Mar 27 '24 19:03 cursive-ide

Just investigating how to set this up. It sounds like your project setup was something like this page, correct?

https://www.jetbrains.com/help/idea/remote-development-starting-page.html

Just putting this out there as a possible workaround, there appears to be an option called WSLg, which runs IntelliJ with GUI natively inside WSL. I imagine that might work better, if you're able to have everything running inside WSL. Sounds like it depends on being able to move your project source into WSL, which might not be the case depending on your work environment.

cursive-ide avatar Mar 27 '24 20:03 cursive-ide

Just investigating how to set this up. It sounds like your project setup was something like this page, correct?

https://www.jetbrains.com/help/idea/remote-development-starting-page.html

I believe so. Here are my steps.

  1. Install WSL2, Ubuntu 22.04.
  2. On the WSL2 Host (type wsl at the command prompt), clone the open-source repository I linked above. So, the source is in the Ubuntu host, not mounted from Windows.
  3. Back in Windows, start up Intellij, a new remote project via WSL, as described in the link you posted.
  4. Try to enable profiles.

Just putting this out there as a possible workaround, there appears to be an option called WSLg, which runs IntelliJ with GUI natively inside WSL. I imagine that might work better, if you're able to have everything running inside WSL. Sounds like it depends on being able to move your project source into WSL, which might not be the case depending on your work environment.

Thanks. Initially, I looked at that plugin, and it doesn't look very well maintained. I don't want to run IDE through X since I've not had great experiences running IDEs through X in the past.

64BitChris avatar Mar 27 '24 20:03 64BitChris

Unfortunately this is going to be hard to reproduce, I just tried to set it all up but WSL2 isn't supported inside parallels on Apple Silicon. I'll try just setting up a remote env on my mac and connecting over SSL to see if I can repro the bug that way.

cursive-ide avatar Mar 28 '24 00:03 cursive-ide

Ok, I've managed to reproduce this using just SSH, so it's a general problem with the remote gateway I think.

cursive-ide avatar Mar 28 '24 01:03 cursive-ide

This is awesome!

MikeMcMahon avatar Mar 28 '24 04:03 MikeMcMahon

:-) Just to temper expectations, I may not be able to do much about this without a lot of support from JetBrains, and possibly also changes on their end, I'm not sure. I'm waiting to hear back from them now.

cursive-ide avatar Mar 28 '24 05:03 cursive-ide

Ok, so JetBrains are being fairly unresponsive on this, which I think is because there isn't a good answer to it yet. The most I have managed to get out of them is:

Hi! We are slowly moving towards providing guidance on those setup. Many features will just work out of the box, only custom UI usually a problem

Of course, this is custom UI, and Cursive has lots more custom UI in various places. I'm still waiting for final confirmation, but it seems like this might not be possible in the near future. I also set up a repro project to test, and the Maven integration has the same problem with its profile selector, so they haven't even fixed this for their own setup yet. I guess profile use is not as common in the Maven world as in the Clojure world, but it doesn't bode well.

So, I think there are two possible options:

  1. Use WSLg, as detailed above. I've seen some users reporting success with this, but I can't test it myself because of the WSL2/Apple Silicon issue.
  2. I might be able to fix the Run Targets support more easily (#2533). That would mean that you'd develop on your local Windows system, and then run the app inside WSL using this support. I don't know if this is feasible for your projects, let me know if so and I'll investigate this option.

Sorry I don't have a better answer here.

cursive-ide avatar Apr 10 '24 04:04 cursive-ide

Thanks for looking into this so deeply, Colin.

Unfortunately, I don't think either of those options will really work for me at this time. I've been using VS Code/Calva because it works seamlessly with WSL. It can mount the WSL filesystem like it's local, then runs the REPL and connects via nREPL. It's so seamless that I don't even notice that I'm working on a Windows computer running WSL.

That said, Calva doesn't have near the support that Cursive does when it comes to jumping around between Java and Clojure source code (maybe because it needs to create this dependency map in memory like Cursive/IDEA does, and perhaps that's the problem).

So, while I'm a big supporter, and always have been, of Cursive, I will have to continue using Calva for the time being. So, I wouldn't worry about prioritizing this too much for me - but I'd have to think that remote development (via SSH, Dev Containers, WSL, Spaces (though that's a weird one), etc) is on the rise, especially for traditional linux/windows users as myself. For the first time, with the WSL and Windows 11, I don't feel like I have to dual boot in order to get the development experience of Linux and the QoL, Adobe Apps, Games, etc, that I get with Windows.

As you said, it sounds like a problem with remote development in general with IDEA, and not necessarily my specific configuration. This feels like a growing channel with users who will be shut out of IDEA/Cursive just because this support isn't there.

So while it's no longer a top priority for me, I hope you can resolve it so you can attract more users like me in the future.

64BitChris avatar Apr 10 '24 14:04 64BitChris

Thanks Chris, and I think using Calva makes total sense in this case - VS Code is famous for having a great remote development story. I agree this is an area JetBrains will have to improve, and I'll keep at them to see if I can make it better. I'll update this issue if there's any further news. I'll also fix the run targets support, in case that helps someone in the meantime.

cursive-ide avatar Apr 10 '24 20:04 cursive-ide

Actually, in an unexpected turnaround, I just found the related YouTrack issue for the Maven profiles problem. There's a workaround mentioned there - if you double click the profile rather than using the checkbox, then it works. I just tested this, and the same thing works for deps aliases (and presumably lein profiles, it's using the same code). So, it's a little unintuitive, but you can double click the profile/alias and then refresh, and it will be selected.

All of the above comments still apply, of course, but that might be enough to continue being able to work.

cursive-ide avatar Apr 10 '24 20:04 cursive-ide